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

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this Validations.

RenderFragmentnull
EditContext

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.

EditContextnull
HandlerType

Specifies the default handler type that will be used by the validation, unless it is overriden by HandlerType property.

Typenull
MissingFieldsErrorMessage

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

string
Mode

Specifies the validation mode for validations inside of this container.

Possible values:Auto, Manual

ValidationModeValidationMode.Auto
Model

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.

objectnull
ValidateOnLoad

If set to true, and Mode is set to Auto, validation will run automatically on page load.

Remarks

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.

booltrue

Validation

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this Validation.

RenderFragmentnull
HandlerType

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

Typenull
Status

Gets the last received validation status.

Possible values:None, Success, Warning, Error

ValidationStatusValidationStatus.None
UsePattern

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

boolfalse

ValidationNone

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this ValidationNone.

RenderFragmentnull

ValidationSuccess

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this ValidationSuccess.

RenderFragmentnull
Tooltip

Shows the tooltip instead of label.

boolfalse

ValidationWarning

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this ValidationWarning.

RenderFragmentnull
Multiline

If true, shows the multiline warning messages.

boolfalse
Tooltip

If true, shows the tooltip instead of label.

boolfalse

ValidationError

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this ValidationError.

RenderFragmentnull
Multiline

If true, shows the multiline error messages.

boolfalse
Tooltip

If true, shows the tooltip instead of label.

boolfalse

ValidationFeedback

Parameter Description TypeDefault
ChildContent

Specifies the content to be rendered inside this ValidationFeedback.

RenderFragmentnull
Error

Content rendered when the validation status is Error.

RenderFragmentnull
Multiline

If true, shows multiline validation messages.

boolfalse
None

Content rendered when the validation status is None.

RenderFragmentnull
Success

Content rendered when the validation status is Success.

RenderFragmentnull
Tooltip

If true, shows the validation message as a tooltip.

boolfalse
Warning

Content rendered when the validation status is Warning.

RenderFragmentnull

Events

Validations

Event Description Type
FailedValidationsChanged

Event is fired whenever the failed validation messages change.

EventCallback<FailedValidationsEventArgs>
StatusChanged

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

EventCallback<ValidationsStatusChangedEventArgs>
ValidatedAll

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

EventCallback

Validation

Event Description Type
AsyncValidator

Gets the asynchronous validator handler attached to this validation.

Func<ValidatorEventArgs, CancellationToken, Task>
MessageLocalizer

Overrides the message that is going to be shown on the ValidationError or ValidationSuccess.

Func<string, IEnumerable<string>, string>
StatusChanged

Occurs each time that validation status changed.

EventCallback<ValidationStatus>
Validator

Gets the validator handler attached to this validation.

Action<ValidatorEventArgs>

Methods

Validations

Method DescriptionReturnParameters
ClearAll Clears all validation statuses. Task
NotifyValidationInitialized Notifies the validation system that a new validation component has been initialized and adds it to the list of validations if not already present. voidIValidation validation
NotifyValidationRemoved Notifies the validation system that a validation component is being removed and removes it from the list of validations if present. voidIValidation validation
NotifyValidationStatusChanged 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.
Remarks

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.

voidIValidation validation
RetriggerValidation Retriggers validations for the specified model fields. TaskExpression<Func<object>>[] expressions
RetriggerValidation Retriggers validations that match the given FieldIdentifier instances. TaskFieldIdentifier[] fieldIdentifiers
ValidateAll Asynchronously runs the validation process for all validations and returns false if any is failed. Task<bool>

Validation

Method DescriptionReturnParameters
Clear Clears the validation status. void
InitializeInputExpression Initializes or updates the input based on a specified expression. This is primarily used for data-annotation validation.
Remarks

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.

TaskExpression<Func<T>> expression
InitializeInputPattern 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.
Remarks

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.

Taskstring patternString, T value
InitializeInput 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.
Remarks

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.

TaskIValidationInput inputComponent
NotifyInputChanged Notifies that an input's value has changed and optionally re-validates the input.
Remarks

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.

TaskT newExpressionValue, bool overrideNewValue
NotifyValidationStarted Notifies the validation that validation process has being activated. void
NotifyValidationStatusChanged Notifies the validation with the new status and messages. voidValidationStatus status, IEnumerable<string> messages
RetriggerValidation Runs the asynchronous validation process using the current input value. Can be used to manually retrigger validation. Task<ValidationStatus>
ValidateAsync Runs the asynchronous validation process based on the last available value. Task<ValidationStatus>
ValidateAsync Runs the asynchronous validation process. Task<ValidationStatus>object newValidationValue
Validate Runs the validation process. ValidationStatus
Validate Runs the validation process. ValidationStatusobject newValidationValue
On this page