sahih_validator 2.1.2
sahih_validator: ^2.1.2 copied to clipboard
A comprehensive validation library for Flutter and Dart applications
SahihValidator 🔐 #
A comprehensive, robust, and modern validation library for Flutter and Dart. Designed for speed, type safety, and global applications.
Features ✨ #
- 📧 Identity: Email (RFC-compliant) & Phone (10-15 digits international)
- 🔒 Security: Simple login & Strong password strength with entropy analysis
- 🌐 Navigation: Asynchronous URL validation with domain/DNS verification
- 🏠 Components: Detailed Address, Date of Birth (Age restriction), & Custom regex
- 🌍 Multi-Language: Built-in support for 11 languages with global & per-call configuration
- 🎯 Developer Experience: Seamless Form integration, 100% Type Safety, & Nullable return types
Quick Start 🚀 #
Core Usage #
import 'package:sahih_validator/sahih_validator.dart';
// 1. Email & Phone
String? email = SahihValidator.email(email: "user@example.com");
String? phone = SahihValidator.phone(phone: "+1234567890");
// 2. Strong Password (8+ chars, upper, lower, digit, entropy score)
String? strength = SahihValidator.passwordParts("MyP@ssword123!");
// 3. Async URL (with domain whitelist)
bool isValid = await SahihValidator.urlAsync<bool>(
"https://pub.dev",
allowedDomains: ["pub.dev", "github.com"],
);
Multi-Language Support 🌍 #
Set once globally or override per call. Supports:
🇺🇸 en, 🇸🇦 ar, 🇪🇸 es, 🇫🇷 fr, 🇩🇪 de, 🇨🇳 zh, 🇯🇵 ja, 🇵🇹 pt, 🇮🇳 hi, 🇷🇺 ru, 🇹🇷 tr
// Global (Set in main)
SahihValidator.lang = SahihLanguage.ar;
// Per-call override
SahihValidator.email(email: "", lang: SahihLanguage.es); // "Por favor..."
Form Integration 📝 #
TextFormField(
validator: (value) => SahihValidator.email(email: value ?? ''),
decoration: InputDecoration(labelText: "Email Address"),
)
Advanced Customization ⚙️ #
String? error = SahihValidator.custom(
value: "john_doe",
title: "Username",
minLength: 3,
pattern: r'^[a-z_]+$',
customValidator: (v) => v.contains("_") ? null : "Must include underscore",
);
Best Practices 💡 #
- Use
loginPasswordfor logins andpasswordPartsfor registrations. - Keep
trimWhitespace: trueto handle accidental user trailing spaces. - Leverage
existingEmails/existingPhoneslists to prevent duplicates.
License & Support 🤝 #
- Developed by Felopater Sameh
- Licensed under MIT
- Found a bug? Open an issue on GitHub