I have a .NET 8 Blazor project where I have created some custom validation attributes. When using @rendermode InteractiveServer, they work as expected. However, when using SSR, the error messages aren't being displayed.
public class MinimumLength(int minLength) : ValidationAttribute{ private readonly string _defaultErrorMessage = $"Minimum length is {minLength}"; protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) { var errorMessage = string.IsNullOrEmpty(ErrorMessage) ? _defaultErrorMessage : ErrorMessage; if (value is string stringValue && stringValue.Length >= minLength) { return ValidationResult.Success; } return new ValidationResult(errorMessage); }}My form is an EditForm with an OnValidSubmit="HandleSubmit". If the custom validation fails, HandleSubmit isn't called, but the error message isn't displayed in <ValidationMessage />. The error message is only written in the <ValidationSummary />. However, I would like them to be written beneath the given field.
When using a built-in validation attributes, like [Required], everything works as expected.
Can anyone tell me what I need to change to achieve this behavior?
Thanks
/Morten