Class RadzenCustomValidator
A validator component which compares a component value with a specified value. Must be placed inside a RadzenTemplateForm<TItem>
public class RadzenCustomValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormValidator
- Inheritance
-
RadzenCustomValidator
- Implements
- Inherited Members
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()));
}
}
Constructors
RadzenCustomValidator()
public RadzenCustomValidator()
Properties
Text
Gets or sets the message displayed when the component is invalid. Set to "Value should match"
by default.
[Parameter]
public override string Text { get; set; }
Property Value
Validator
Specifies the function which validates the component value. Must return true
if the component is valid.
[Parameter]
public Func<bool> Validator { get; set; }
Property Value
Methods
Validate(IRadzenFormComponent)
protected override bool Validate(IRadzenFormComponent component)
Parameters
component
IRadzenFormComponent