Class RadzenDataAnnotationValidator
A validator component which validates a component value using the data annotations defined on the corresponding model property. Must be placed inside a RadzenTemplateForm<TItem>
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenDataAnnotationValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormValidator
Examples
<RadzenTemplateForm TItem="UserModel" Data=@user>
<RadzenTextBox style="display: block" Name="Name" @bind-Value=@user.Name />
<RadzenFieldValidator Component="Name" />
</RadzenTemplateForm>
@code {
class UserModel
{
[Required(ErrorMessage = "Name is required.")]
[StringLength(50, ErrorMessage = "Name must be less than 50 characters.")]
public string Name { get; set; }
}
UserModel user = new UserModel();
}
Constructors
RadzenDataAnnotationValidator()
A validator component which validates a component value using the data annotations defined on the corresponding model property. Must be placed inside a RadzenTemplateForm<TItem>
Declaration
public RadzenDataAnnotationValidator()
Examples
<RadzenTemplateForm TItem="UserModel" Data=@user>
<RadzenTextBox style="display: block" Name="Name" @bind-Value=@user.Name />
<RadzenFieldValidator Component="Name" />
</RadzenTemplateForm>
@code {
class UserModel
{
[Required(ErrorMessage = "Name is required.")]
[StringLength(50, ErrorMessage = "Name must be less than 50 characters.")]
public string Name { get; set; }
}
UserModel user = new UserModel();
}
Properties
MessageSeparator
Gets or sets the separator used to join multiple validation messages.
Declaration
[Parameter]
public string MessageSeparator { get; set; }
Property Value
Type | Description |
---|---|
string |
Text
Gets or sets the message displayed when the component is invalid. The message is generated from the data annotation attributes applied to the model property.
Declaration
[Parameter]
public override string Text { get; set; }
Property Value
Type | Description |
---|---|
string |
Overrides
Methods
Validate(IRadzenFormComponent)
Runs validation against the specified component.
Declaration
protected override bool Validate(IRadzenFormComponent component)
Parameters
Type | Name | Description |
---|---|---|
IRadzenFormComponent | component | The component to validate. |
Returns
Type | Description |
---|---|
bool |
|