C
C#2y 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="[email protected]"/>
<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>
<EditForm EditContext="_merchantContext" class="create-link-form">
<DataAnnotationsValidator />

<div class="form-control">
<Name For="() => _merchant.EmailAddress" />
<InputText type="text" @bind-Value="_merchant.EmailAddress" placeholder="[email protected]"/>
<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);
}
private void SubmitPart(EditContext context) {
var result = context.Validate();

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

GoTo(_currentPage+1);
}
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server