A validator component that ensures a text input's length falls within a specified minimum and maximum range. RadzenLengthValidator is useful for enforcing username lengths, password complexity, or limiting text field sizes. Must be placed inside a RadzenTemplateForm<T> and associated with a named input component. Checks the string length against optional Min and Max constraints. If only Min is set, validates minimum length. If only Max is set, validates maximum length. If both are set, the length must be within the range (inclusive). Null or empty values are considered invalid if Min is set, and valid if only Max is set.
ValidatorBase.SetParametersAsync
ValidatorBase.GetComponentCssClass
RadzenComponent.OnAfterRenderAsync
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnInitializedAsync
ComponentBase.OnParametersSet
ComponentBase.OnParametersSetAsync
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.OnAfterRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenLengthValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormValidator<RadzenTemplateForm TItem="Model" Data=@model>
<RadzenTextBox style="display: block" Name="FirstName" @bind-Value=@model.FirstName />
<RadzenLengthValidator Component="FirstName" Min="3" Text="First name should be at least 3 characters" Style="position: absolute" />
</RadzenTemplateForm>
@code {
class Model
{
public string FirstName { get; set; }
}
Model model = new Model();
}A validator component that ensures a text input's length falls within a specified minimum and maximum range. RadzenLengthValidator is useful for enforcing username lengths, password complexity, or limiting text field sizes. Must be placed inside a RadzenTemplateForm<T> and associated with a named input component. Checks the string length against optional Min and Max constraints. If only Min is set, validates minimum length. If only Max is set, validates maximum length. If both are set, the length must be within the range (inclusive). Null or empty values are considered invalid if Min is set, and valid if only Max is set.
public RadzenLengthValidator()Specifies the maximum accepted length. The component value length should be less than the maximum in order to be valid.
public int? Max { get; set; }
| Type | Description |
|---|---|
| int? | Specifies the maximum accepted length. The component value length should be less than the maximum in order to be valid. |
Specifies the minimum accepted length. The component value length should be greater than the minimum in order to be valid.
public int? Min { get; set; }
| Type | Description |
|---|---|
| int? | Specifies the minimum accepted length. The component value length should be greater than the minimum in order to be valid. |
Gets or sets the message displayed when the component is invalid. Set to "Invalid length" by default.
public string Text { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the message displayed when the component is invalid. Set to "Invalid length" by default. |
protected override bool Validate(IRadzenFormComponent component)
| Type | Name | Description |
|---|---|---|
| IRadzenFormComponent | component |
| Type | Description |
|---|---|
| bool |