Blazorise Validation API

Explore the Blazorise Validation API reference for parameters, events, methods, and related types.

For examples and usage guidance, see the Validation documentation.

API

Parameters

Validations

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this Validations.
EditContextnullEditContext

Supplies the edit context explicitly. If using this parameter, do not also supply Model, since the model value will be taken from the EditContext.Model property.
HandlerTypenullType

Specifies the default handler type that will be used by the validation, unless it is overriden by HandlerType property.
MissingFieldsErrorMessageOne or more fields have an error. Please check and try again.string

Message that will be displayed if any of the validations does not have defined error message.
ModeAutoValidationMode

Specifies the validation mode for validations inside of this container.
Possible values:AutoManual
Modelnullobject

Specifies the top-level model object for the form. An edit context will be constructed for this model. If using this parameter, do not also supply a value for EditContext.
ValidateOnLoadtruebool

If set to true, and Mode is set to Auto, validation will run automatically on page load.
When validation is placed inside of modal dialog, the behavior is a little different. Modals are by definition always loaded and are always present in the DOM so no loading is ever happening again after the page that contains the modal is first initialized. Their visibility is controlled by display: none; To workaround this, the actual "first load" for modals can be done by re-initializing Model parameter.

Validation

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this Validation.
HandlerTypenullType

Forces the custom validation handler to be used while validating the values.
StatusValidationStatus.NoneValidationStatus

Gets the last received validation status.
Possible values:NoneSuccessWarningError
UsePatternfalsebool

Forces validation to use regex pattern matching instead of default validator handler.

ValidationNone

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this ValidationNone.

ValidationSuccess

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this ValidationSuccess.
Tooltipfalsebool

Shows the tooltip instead of label.

ValidationWarning

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this ValidationWarning.
Multilinefalsebool

If true, shows the multiline warning messages.
Tooltipfalsebool

If true, shows the tooltip instead of label.

ValidationError

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this ValidationError.
Multilinefalsebool

If true, shows the multiline error messages.
Tooltipfalsebool

If true, shows the tooltip instead of label.

ValidationFeedback

ParameterDefaultType
ChildContentnullRenderFragment

Specifies the content to be rendered inside this ValidationFeedback.
ErrornullRenderFragment

Content rendered when the validation status is Error.
Multilinefalsebool

If true, shows multiline validation messages.
NonenullRenderFragment

Content rendered when the validation status is None.
SuccessnullRenderFragment

Content rendered when the validation status is Success.
Tooltipfalsebool

If true, shows the validation message as a tooltip.
WarningnullRenderFragment

Content rendered when the validation status is Warning.

Events

Validations

EventType
FailedValidationsChangedEventCallback<FailedValidationsEventArgs>

Event is fired whenever the failed validation messages change.
StatusChangedEventCallback<ValidationsStatusChangedEventArgs>

Event is fired whenever there is a change in validation status.
ValidatedAllEventCallback

Event is fired only after all of the validation are successful.

Validation

EventType
AsyncValidatorFunc<ValidatorEventArgs, CancellationToken, Task>

Gets the asynchronous validator handler attached to this validation.
MessageLocalizerFunc<string, IEnumerable<string>, string>

Overrides the message that is going to be shown on the ValidationError or ValidationSuccess.
StatusChangedEventCallback<ValidationStatus>

Occurs each time that validation status changed.
ValidatorAction<ValidatorEventArgs>

Gets the validator handler attached to this validation.

Methods

Validations

MethodReturnParameters
ClearAllTask—

Clears all validation statuses.
NotifyValidationInitializedvoidIValidation validation

Notifies the validation system that a new validation component has been initialized and adds it to the list of validations if not already present.
NotifyValidationRemovedvoidIValidation validation

Notifies the validation system that a validation component is being removed and removes it from the list of validations if present.
NotifyValidationStatusChangedvoidIValidation validation

Notifies the validation system that the status of a validation component has changed. This method handles the logic for updating the overall validation status based on the mode (Auto or Manual) and the current validation results.
In Auto mode, this method triggers the aggregation of validation results and potentially raises a status changed event. It is designed to minimize the number of status changed events by aggregating validation results. Special consideration is needed to ensure that the status changed event is raised only once per validation cycle, even if multiple validations fail.
RetriggerValidationTaskExpression<Func<object>>[] expressions

Retriggers validations for the specified model fields.
RetriggerValidationTaskFieldIdentifier[] fieldIdentifiers

Retriggers validations that match the given FieldIdentifier instances.
ValidateAllTask<bool>—

Asynchronously runs the validation process for all validations and returns false if any is failed.

Validation

MethodReturnParameters
Clearvoid—

Clears the validation status.
InitializeInputExpressionTaskExpression<Func<T>> expression

Initializes or updates the input based on a specified expression. This is primarily used for data-annotation validation.
This method is designed to work with models and edit contexts, allowing for dynamic validation based on expressions. It ensures that validation is only re-triggered if the component has been initialized and validation conditions are met.
InitializeInputPatternTaskstring patternString, T value

Initializes or updates the input validation pattern. If the pattern string changes, a new regex pattern is created, and the input is re-validated if applicable.
This method optimizes performance by avoiding re-instantiation of the regex pattern if it has not changed. It ensures that validation is only re-triggered if the component has been initialized and validation conditions are met.
InitializeInputTaskIValidationInput inputComponent

Initializes the input component with the specified validation input. It performs an initial validation if the mode is set to auto validation and validation on load is enabled.
This method sets the input component and, based on the configuration, may asynchronously validate the component's validation value. It also marks the component as initialized.
NotifyInputChangedTaskT newExpressionValue, bool overrideNewValue

Notifies that an input's value has changed and optionally re-validates the input.
If the edit context is set and a field identifier has been established, this method notifies the edit context of the field change. It then conditionally triggers validation based on the component's mode.
NotifyValidationStartedvoid—

Notifies the validation that validation process has being activated.
NotifyValidationStatusChangedvoidValidationStatus status, IEnumerable<string> messages

Notifies the validation with the new status and messages.
RetriggerValidationTask<ValidationStatus>—

Runs the asynchronous validation process using the current input value. Can be used to manually retrigger validation.
ValidateAsyncTask<ValidationStatus>—

Runs the asynchronous validation process based on the last available value.
ValidateAsyncTask<ValidationStatus>object newValidationValue

Runs the asynchronous validation process.
ValidateValidationStatus—

Runs the validation process.
ValidateValidationStatusobject newValidationValue

Runs the validation process.