SahihValidator class
A comprehensive validation library for Flutter applications.
Provides static methods for validating emails, phone numbers, passwords,
addresses, URLs, and custom fields. All methods return null for valid input
or an error message string for invalid input.
A collection of static validation methods for common input types.
This class provides validation for:
- Email addresses
- Phone numbers
- Passwords
- Addresses
- URLs
- Custom validation rules A comprehensive validator for common input types in Flutter applications.
Provides static methods for validating:
- Email addresses
- Phone numbers
- Passwords
- Addresses
- URLs
- Custom input patterns
All methods return null if validation passes, or a String error message
if validation fails.
Constructors
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
-
address(
{required String address, String? title = "Address", String? emptyMessage, bool trimWhitespace = true, List< String> ? existingAddresses, String? alreadyExistsMessage, bool isRequired = true, int minLength = 10, int maxLength = 200, bool requireStreetNumber = false, bool requireStreetName = true, bool requireCity = false, bool requireCountry = false, bool allowSpecialChars = true, bool allowNumbers = true, bool allowLetters = true, List<String> ? forbiddenWords, List<String> ? requiredWords, String? minLengthMessage, String? maxLengthMessage, String? missingStreetNumberMessage, String? missingStreetNameMessage, String? missingCityMessage, String? missingCountryMessage, String? invalidSpecialCharsMessage, String? invalidNumbersMessage, String? invalidLettersMessage, String? forbiddenWordsMessage, String? requiredWordsMessage}) → String? - Validates physical addresses with comprehensive formatting and content rules.
-
custom(
{required String value, String? title, bool trimWhitespace = true, bool isRequired = true, int? minLength, int? maxLength, String? pattern, PatternType? patternType, bool allowOnlyNumbers = false, bool allowOnlyLetters = false, String? emptyMessage, String? minLengthMessage, String? maxLengthMessage, String? invalidPatternMessage, String? invalidNumberMessage, String? invalidLettersMessage, String? customValidator(String value)?, List< String> ? existingValues, String? alreadyExistsMessage}) → String? - Provides flexible custom validation with multiple configurable rules.
-
dateOfBirth(
{required String dob, String format = "yyyy-MM-dd", int minAgeYears = 18, int maxAgeYears = 120, int? minAgeDays, bool useUtc = false, String? invalidFormatMessage, String? futureDateMessage, String? tooYoungMessage, String? tooOldMessage}) → String? -
email(
{required String email, String? emptyMessage, String? invalidFormatMessage, bool trimWhitespace = true, List< String> ? existingEmails, String? alreadyExistsMessage}) → String? - Validates an email address format and checks against existing emails.
-
loginPassword(
{required String password, String? emptyMessage}) → String? - Validates a login password by checking if it's not empty.
-
passwordParts(
String input, {List< String> ? commonPasswords}) → String? - Validates password strength for new password creation.
-
phone(
{required String phone, String? emptyMessage, String? invalidFormatMessage, bool trimWhitespace = true, List< String> ? existingPhones, String? alreadyExistsMessage}) → String? - Validates a phone number format and checks against existing phone numbers.
-
urlAsync<
T> (String url, {bool allowRelative = false, List< String> ? allowedSchemes, List<String> ? allowedDomains, bool normalize = true, bool checkDomainExists = false}) → Future<T> - Asynchronously validates URLs with comprehensive format and domain checking.