sahih_validator 2.1.2 copy "sahih_validator: ^2.1.2" to clipboard
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.

Pub Version License: MIT

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 loginPassword for logins and passwordParts for registrations.
  • Keep trimWhitespace: true to handle accidental user trailing spaces.
  • Leverage existingEmails / existingPhones lists to prevent duplicates.

License & Support 🤝 #

1
likes
150
points
82
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A comprehensive validation library for Flutter and Dart applications

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

intl

More

Packages that depend on sahih_validator