discontinuedPackage webapp has been discontinued and replaced by finch.

FieldValidator class

A utility class providing common field validators.

The FieldValidator class contains static methods for common validation tasks, such as checking if a field is required, validating the length of a string, or ensuring a field is a number or an email address.

Constructors

FieldValidator()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fieldLength({int? max, int? min}) → ValidatorEvent
Validator to check if a field's length falls within a specified range.
hasRelation({required DBCollectionFree collectionModel, String relationField = '_id', bool isRequired = true}) → ValidatorEvent
isColorField() → ValidatorEvent
Validator to check if a field contains a valid color code. The color code must be a valid hexadecimal color code. The validator checks whether the provided value is non-null, is a non-empty string, and matches the format of a color code. If the validation fails, an error message 'error.field.color' is returned.
isEmailField() → ValidatorEvent
Validator to check if a field contains a valid email address.
isNumberDoubleField({double? max, double? min, bool isRequired = false}) → ValidatorEvent
Validator to check if a field is a valid number within optional bounds.
isNumberField({int? max, int? min, bool isRequired = false}) → ValidatorEvent
Validator to check if a field is a valid number within optional bounds.
isPasswordField() → ValidatorEvent
Validator to check if a field contains a valid password. The password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one number, and one special character. The validator checks whether the provided value is non-null, is a non-empty string, and matches the format of a password. If the validation fails, an error message 'error.field.password' is returned.
isSelectField(List options) → ValidatorEvent
Validator to check if a field contains a valid select field. The select field must be a valid value from the list of options. The validator checks whether the provided value is non-null, is a non-empty string, and matches the format of a select field. If the validation fails, an error message 'error.field.select' is returned.
requiredField() → ValidatorEvent
Validator to check if a field is required (non-null and non-empty).
requiredFieldMultiLanguage() → ValidatorEvent
Validator to check if a field is required in multiple languages.