RtCommonValidation class
Common validation constants and rules used throughout the application.
RtCommonValidation implements the singleton pattern and provides centralized
access to validation constraints such as field lengths, file size limits,
and other validation-related constants.
This class defines validation rules for:
- Text field lengths (first name, last name, email, password, etc.)
- Media constraints (photo size, video duration)
- API configurations (timeout, pagination)
- Default values (country code)
Example:
// Check if email length is valid
if (email.length >= Utils.commonValidation.emailMinLength &&
email.length <= Utils.commonValidation.emailMaxLength) {
// Process email
}
// Use in TextFormField
TextFormField(
maxLength: Utils.commonValidation.firstNameMaxLength,
validator: (value) {
if (value == null || value.length < Utils.commonValidation.firstNameMinLength) {
return 'Name too short';
}
return null;
},
);
Constructors
- RtCommonValidation()
-
Factory constructor returning the singleton instance.
factory
Properties
- apiTimeoutInSeconds ↔ int
-
API request timeout duration in seconds.
getter/setter pair
- defaultCountryCode ↔ String
-
Default country calling code for phone numbers.
getter/setter pair
- emailMaxLength ↔ int
-
Maximum character length for email fields.
getter/setter pair
- emailMinLength ↔ int
-
Minimum character length for email fields.
getter/setter pair
- firstNameMaxLength ↔ int
-
Maximum character length for first name fields.
getter/setter pair
- firstNameMinLength ↔ int
-
Minimum character length for first name fields.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- lastNameMaxLength ↔ int
-
Maximum character length for last name fields.
getter/setter pair
- lastNameMinLength ↔ int
-
Minimum character length for last name fields.
getter/setter pair
- maxNoteLength ↔ int
-
Maximum character length for note fields.
getter/setter pair
-
Maximum character length for share message fields.
getter/setter pair
- nameMaxLength ↔ int
-
Maximum character length for generic name fields.
getter/setter pair
- nameMinLength ↔ int
-
Minimum character length for generic name fields.
getter/setter pair
- pageLimit ↔ int
-
Default number of items per page for paginated lists.
getter/setter pair
- passMaxLength ↔ int
-
Maximum character length for password fields.
getter/setter pair
- passMinLength ↔ int
-
Minimum character length for password fields.
getter/setter pair
- phoneMaxLength ↔ int
-
Maximum character length for phone number fields.
getter/setter pair
- photoMaxMbValidation ↔ int
-
Maximum file size for photos in megabytes.
getter/setter pair
- photoPreferredMbValidation ↔ double
-
Preferred maximum file size for photos in megabytes.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- videoMaxLengthInSeconds ↔ int
-
Maximum duration for video uploads in seconds.
getter/setter pair
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 Properties
- instance → RtCommonValidation
-
Returns the singleton instance of RtCommonValidation.
no setter