C#C
C#3y ago
Rese

❔ Custom validation attribute not displaying validation message

I'll butt in with a bit of a question. I'm using an EditForm in Blazor Server, where I directly pass it the EditContext and manually trigger the validation logic. Got a bit of an issue where if I validate something using a CustomAttribute, the validation result will blink for a bit in the validation message and then disappear. It's still there if I use a ValidationSummary, but not in the Validation Message for the specific field. Anyone got any idea why?

form:
<EditForm EditContext="_merchantContext" class="create-link-form">
            <DataAnnotationsValidator />

            <div class="form-control">
                <Name For="() => _merchant.EmailAddress" />
                <InputText type="text" @bind-Value="_merchant.EmailAddress" placeholder="example@example.com"/>
                <ValidationMessage For="() => _merchant.EmailAddress" />
            </div>

            <div class="form-control">
                <Name For="() => _merchant.Iban" />
                <InputText class="uppercase" type="text" @bind-Value="_merchant.Iban" placeholder="SKXX XXXX XXXX XXXX XXXX XXXX" />
                <ValidationMessage For="() => _merchant.Iban" />
            </div>
        </EditForm>


Validate call:
private void SubmitPart(EditContext context) {
        var result = context.Validate();

        if(!result) {
            _isSubmitting = false;
            return;
        }

        GoTo(_currentPage+1);
    }
Was this page helpful?