Class RadzenCustomValidator
A validator component which compares a component value with a specified value. Must be placed inside a RadzenTemplateForm<TItem>
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenCustomValidator : ValidatorBase, IDisposable, IRadzenFormValidator
Examples
<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenTextBox Name="Email" @bind-Value=@model.Email />
<RadzenCustomValidator Value=@model.Email Component="Email" Text="Email must be unique" Validator="@(() => ValidateNewEmail(model.Email))" Style="position: absolute" />
</RadzenTemplateForm>
@code {
class Model
{
public string Email { get; set; }
}
Model model = new Model();
string[] emails = new string[] { "andy@smith" };
bool ValidateNewEmail(string email)
{
return !emails.Any(e => e.ToUpper().Equals(email.ToUpper()));
}
}
Properties
Text
Gets or sets the message displayed when the component is invalid. Set to "Value should match"
by default.
Declaration
public override string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Overrides
Validator
Specifies the function which validates the component value. Must return true
if the component is valid.
Declaration
public Func<bool> Validator { get; set; }
Property Value
Type | Description |
---|---|
Func<System.Boolean> |
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 |
---|---|
System.Boolean |
|
Overrides
Implements
IDisposable