Class RadzenRequiredValidator
A validator component that ensures a form input component has a non-empty value. RadzenRequiredValidator verifies that required fields are filled before form submission. Must be placed inside a RadzenTemplateForm<TItem> and associated with a named input component. Checks if the associated component has a value (HasValue returns true) and that the value is not equal to the optional DefaultValue. For text inputs, an empty string is considered invalid. For dropdowns and other components, null or default values are considered invalid. The validation message can be customized via the Text property and displayed inline, as a block, or as a popup depending on the Style property.
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenRequiredValidator : ValidatorBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IRadzenFormValidatorExamples
Basic required field validation:
<RadzenTemplateForm TItem="Model" Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
 class Model
 {
   public string Email { get; set; }
 }
 Model model = new Model();
}Dropdown validation with default value:
<RadzenDropDown Name="Country" @bind-Value=@model.CountryId Data=@countries />
<RadzenRequiredValidator Component="Country" DefaultValue="0" Text="Please select a country" />Constructors
RadzenRequiredValidator()
A validator component that ensures a form input component has a non-empty value. RadzenRequiredValidator verifies that required fields are filled before form submission. Must be placed inside a RadzenTemplateForm<TItem> and associated with a named input component. Checks if the associated component has a value (HasValue returns true) and that the value is not equal to the optional DefaultValue. For text inputs, an empty string is considered invalid. For dropdowns and other components, null or default values are considered invalid. The validation message can be customized via the Text property and displayed inline, as a block, or as a popup depending on the Style property.
Declaration
public RadzenRequiredValidator()Examples
Basic required field validation:
<RadzenTemplateForm TItem="Model" Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
 class Model
 {
   public string Email { get; set; }
 }
 Model model = new Model();
}Dropdown validation with default value:
<RadzenDropDown Name="Country" @bind-Value=@model.CountryId Data=@countries />
<RadzenRequiredValidator Component="Country" DefaultValue="0" Text="Please select a country" />Properties
DefaultValue
Gets or sets a default value that should be considered invalid (empty). For example, set to 0 for numeric dropdowns where 0 represents "not selected", or empty Guid for Guid fields. If the component's value equals this DefaultValue, validation will fail.
Declaration
[Parameter]
public object DefaultValue { get; set; }Property Value
| Type | Description | 
|---|---|
| object | The value to treat as empty/invalid. Default is null. | 
Text
Gets or sets the error message displayed when the associated component is invalid (has no value or has the default value). This message helps users understand what is required to pass validation.
Declaration
[Parameter]
public override string Text { get; set; }Property Value
| Type | Description | 
|---|---|
| string | The validation error message. Default is "Required". | 
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 | 
 |