apptomate_utility_validations 0.0.2
apptomate_utility_validations: ^0.0.2 copied to clipboard
A powerful and easy-to-use Dart/Flutter utility package that provides a wide range of input validations for forms and user data including passwords, phone numbers, email, date formats (`MM-yyyy`, `MM- [...]
Apptomate Validator Utils #
A comprehensive validation utility package for Dart/Flutter applications that provides various input validation methods.
Features #
- Password validation (strength, length, special characters)
- Email validation
- Phone number validation
- Zip code validation
- Date validation (MM-YYYY, MM-DD-YYYY formats)
- Common field validation
- Password confirmation validation
- Date range validation
- And more...
Installation #
Add the following to your pubspec.yaml file:
dependencies:
apptomate_validator_utils: ^0.0.2
Then run:
flutter pub get
Usage #
Import the package in your Dart file:
import 'package:apptomate_utility_validations/apptomate_validator_utils.dart';
Available Validators #
1. Password Validation
String? error = Validator.validatePassword("password123");
if (error != null) {
// Show error message
}
2. Email Validation
String? error = Validator.emailValidator("test@example.com");
if (error != null) {
// Show error message
}
3. Phone Number Validation
String? error = Validator.validatePhoneNumber("1234567890");
if (error != null) {
// Show error message
}
4. Zip Code Validation
String? error = Validator.validateZipCode("12345");
if (error != null) {
// Show error message
}
5. Date Validation
// MM-YYYY format
String? error = Validator.mmYYYYValidation("12-2023");
// MM-DD-YYYY format
String? error = Validator.dobValidation("12-31-2023");
6. Date Range Validation
String? error = Validator.toDateValidation(
fromDate: "01-01-2023",
toDate: "12-31-2023"
);
if (error != null) {
// Show error message
}
7. Confirm Password Validation
String? error = Validator.validateConfirmPassword(
"password123",
"password123"
);
if (error != null) {
// Show error message
}
8. Common Field Validation
String? error = Validator.commonValidation(
"Some value",
"Field is required"
);
if (error != null) {
// Show error message
}
Validation Rules #
Password #
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one special character (!@#$&*~)
- No spaces allowed
Email #
- Standard email format validation
Phone Number #
- Exactly 10 digits
Zip Code #
- 5 or 6 digits
Dates #
- MM-YYYY format must be valid month/year
- MM-DD-YYYY format must be valid date
- Date ranges must be logical (to date after from date)
Dependencies #
This package uses:
intlfor date formatting and parsing