I created a custom validation message component in Blazor like this:
<div class="text-danger">
<ValidationMessage For="@(()=>model)"/>
</div>
@code {
[Parameter]
public object model { get; set; }
}
and I have a class:
public class LoginViewModel
{
[Required(ErrorMessage = "please enter {0}")]
public string PhoneNumber { get; set; }
}
then I use this component in a razor page:
<CustomClientValidation model=@(LoginModel.PhoneNumber)/>
and with an object defined in the code section of the page:
LoginViewModel LoginModel;
but after running the application, even though the PhoneNumber is null, the validation message is not displayed. Where is my mistake?