RadzenCompareValidator Class

A validator component that compares a form input's value against another value or another component's value using a specified comparison operator. RadzenCompareValidator is commonly used for password confirmation, numeric range validation, or ensuring field values match expected criteria. Must be placed inside a RadzenTemplateForm<T> and associated with a named input component. Supports various comparison operations (Equal, NotEqual, GreaterThan, LessThan, etc.) via the Operator property. For password confirmation scenarios, set the Value property to the password field and the Component to the confirmation field name. Can react to changes in the comparison value by setting ValidateOnComponentValueChange to true (default).

Inheritance

Object

ComponentBase

RadzenComponent

ValidatorBase

RadzenCompareValidator

Implements

IComponent

IHandleEvent

IHandleAfterRender

IRadzenFormValidator

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenCompareValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormValidator

Examples

<RadzenTemplateForm TItem="Model" Data=@model>
   <RadzenPassword style="display: block" Name="Password" @bind-Value=@model.Password />
   <RadzenPassword style="display: block" Name="RepeatPassword" @bind-Value=@model.RepeatPassword />
   <RadzenCompareValidator Value=@model.Password Component="RepeatPassword" Text="Passwords should be the same"  Style="position: absolute" />
</RadzenTemplateForm>
@code {
   class Model
   {
     public string Password { get; set; }
     public double Value { get; set; }
     public string RepeatPassword { get; set; }
   }
   Model model = new Model();
}

Constructors

RadzenCompareValidatorlink

A validator component that compares a form input's value against another value or another component's value using a specified comparison operator. RadzenCompareValidator is commonly used for password confirmation, numeric range validation, or ensuring field values match expected criteria. Must be placed inside a RadzenTemplateForm<T> and associated with a named input component. Supports various comparison operations (Equal, NotEqual, GreaterThan, LessThan, etc.) via the Operator property. For password confirmation scenarios, set the Value property to the password field and the Component to the confirmation field name. Can react to changes in the comparison value by setting ValidateOnComponentValueChange to true (default).

Declaration
public RadzenCompareValidator()

Properties

Operatorlink

Specifies the comparison operator. Set to CompareOperator.Equal by default.

Declaration
public CompareOperator Operator { get; set; }
Property Value
Type Description
CompareOperatorSpecifies the comparison operator. Set to CompareOperator.Equal by default.

Textlink

Gets or sets the message displayed when the component is invalid. Set to "Value should match" by default.

Declaration
public string Text { get; set; }
Property Value
Type Description
stringGets or sets the message displayed when the component is invalid. Set to "Value should match" by default.

ValidateOnComponentValueChangelink

Gets or sets a value indicating whether this RadzenCompareValidator should be validated on value change of the specified Component.

Declaration
public bool ValidateOnComponentValueChange { get; set; }
Property Value
Type Description
boolGets or sets a value indicating whether this RadzenCompareValidator should be validated on value change of the specified Component.

Valuelink

Specifies the value to compare with.

Declaration
public object Value { get; set; }
Property Value
Type Description
objectSpecifies the value to compare with.

Methods

OnAfterRenderlink

Declaration
protected override void OnAfterRender(bool firstRender)
Parameters
Type Name Description
bool firstRender

SetParametersAsynclink

Declaration
public override Task SetParametersAsync(ParameterView parameters)
Parameters
Type Name Description
ParameterView parameters
Returns
Type Description
Task

Validatelink

Declaration
protected override bool Validate(IRadzenFormComponent component)
Parameters
Type Name Description
IRadzenFormComponent component
Returns
Type Description
bool
An error has occurred. This app may no longer respond until reloaded. Reload 🗙