Class RadzenNumericRangeValidator
A validator component that ensures a numeric value falls within a specified minimum and maximum range. RadzenNumericRangeValidator is ideal for quantity limits, age restrictions, price ranges, or any bounded numeric input. Must be placed inside a RadzenTemplateForm<TItem>. Ensures values are within acceptable bounds by checking that the value is greater than or equal to Min and less than or equal to Max. Both bounds are inclusive. You can specify just Min to validate minimum value (e.g., age must be at least 18), just Max to validate maximum value (e.g., quantity cannot exceed 100), or both to validate range (e.g., rating must be between 1 and 5). Works with any IComparable type (int, decimal, double, DateTime, etc.). Set AllowNull = true to accept null values as valid (for optional nullable fields).
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenNumericRangeValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormValidator
Examples
Age minimum validation:
<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenNumeric Name="Age" @bind-Value=@model.Age />
<RadzenNumericRangeValidator Component="Age" Min="18" Text="Must be 18 or older" Style="position: absolute" />
</RadzenTemplateForm>
Quantity range validation:
<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenNumeric Name="Quantity" @bind-Value=@model.Quantity />
<RadzenNumericRangeValidator Component="Quantity" Min="1" Max="100"
Text="Quantity must be between 1 and 100" Style="position: absolute" />
</RadzenTemplateForm>
Constructors
RadzenNumericRangeValidator()
A validator component that ensures a numeric value falls within a specified minimum and maximum range. RadzenNumericRangeValidator is ideal for quantity limits, age restrictions, price ranges, or any bounded numeric input. Must be placed inside a RadzenTemplateForm<TItem>. Ensures values are within acceptable bounds by checking that the value is greater than or equal to Min and less than or equal to Max. Both bounds are inclusive. You can specify just Min to validate minimum value (e.g., age must be at least 18), just Max to validate maximum value (e.g., quantity cannot exceed 100), or both to validate range (e.g., rating must be between 1 and 5). Works with any IComparable type (int, decimal, double, DateTime, etc.). Set AllowNull = true to accept null values as valid (for optional nullable fields).
Declaration
public RadzenNumericRangeValidator()
Examples
Age minimum validation:
<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenNumeric Name="Age" @bind-Value=@model.Age />
<RadzenNumericRangeValidator Component="Age" Min="18" Text="Must be 18 or older" Style="position: absolute" />
</RadzenTemplateForm>
Quantity range validation:
<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenNumeric Name="Quantity" @bind-Value=@model.Quantity />
<RadzenNumericRangeValidator Component="Quantity" Min="1" Max="100"
Text="Quantity must be between 1 and 100" Style="position: absolute" />
</RadzenTemplateForm>
Properties
AllowNull
Gets or sets whether null values should be considered valid. When true, null values pass validation (useful for optional nullable fields). When false (default), null values fail validation.
Declaration
[Parameter]
public bool AllowNull { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Max
Gets or sets the maximum allowed value (inclusive). The component value must be less than or equal to this value. Can be null to only validate minimum. Works with any IComparable type (int, decimal, DateTime, etc.).
Declaration
[Parameter]
public IComparable Max { get; set; }
Property Value
| Type | Description |
|---|---|
| IComparable | The maximum value, or null for no maximum constraint. |
Min
Gets or sets the minimum allowed value (inclusive). The component value must be greater than or equal to this value. Can be null to only validate maximum. Works with any IComparable type (int, decimal, DateTime, etc.).
Declaration
[Parameter]
public IComparable Min { get; set; }
Property Value
| Type | Description |
|---|---|
| IComparable | The minimum value, or null for no minimum constraint. |
Text
Gets or sets the error message displayed when the value is outside the valid range. Customize to provide specific guidance (e.g., "Age must be between 18 and 65").
Declaration
[Parameter]
public override string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The validation error message. Default is "Not in the valid range". |
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 |
|