just_validation 0.4.0 copy "just_validation: ^0.4.0" to clipboard
just_validation: ^0.4.0 copied to clipboard

A simple and flexible validation library for Dart that provides validators for common use cases.

Changelog #

All notable changes to this project will be documented in this file.

0.4.0 - 2026-01-26 #

Added - DateTime Validators #

  • DateTime validation support: Complete set of validators for date/time validation
  • New DateTime validators:
    • isAfter(date) - Date must be after specified date
    • isAfterOrEqual(date) - Date must be after or equal to specified date
    • isBefore(date) - Date must be before specified date
    • isBeforeOrEqual(date) - Date must be before or equal to specified date
    • isBetween(from, to) - Date must be within range (inclusive)
    • isInPast() - Date must be in the past
    • isInFuture() - Date must be in the future
    • isToday() - Date must be today (ignores time)
    • isSameDay(date) - Date must be same day as specified date
    • isWithinDuration(date, duration) - Date must be within duration of reference date
    • minAge(years) - Validates minimum age (e.g., must be 18+)
    • maxAge(years) - Validates maximum age
  • All DateTime validators support nowProvider parameter for testing

Added - International Identity Document Validators #

  • 26 identity document validators covering 4 continents:

Europe (10 validators):

  • 🇪🇸 dni() / spanishDni() - Spanish DNI (8 digits + letter with checksum)
  • 🇪🇸 nie() / spanishNie() - Spanish NIE (X/Y/Z + 7 digits + letter)
  • 🇬🇧 nin() / ukNationalInsurance() - UK National Insurance Number
  • 🇩🇪 germanId() - German Personalausweis (10 chars with checksum)
  • 🇮🇹 codiceFiscale() / italianFiscalCode() - Italian Fiscal Code (16 chars)
  • 🇵🇹 nif() / portugueseNif() - Portuguese NIF (9 digits, Mod 11)
  • 🇳🇱 bsn() / dutchBsn() - Dutch BSN (9 digits, 11-proof)
  • 🇧🇪 belgianNationalNumber() - Belgian National Number (11 digits, Mod 97)
  • 🇵🇱 pesel() / polishPesel() - Polish PESEL (11 digits)
  • 🇫🇷 frenchNationalId() - French CNI (12 digits)

Americas (11 validators):

  • 🇺🇸 ssn() / usSsn() - US Social Security Number (area/group validation)
  • 🇲🇽 curp() / mexicanCurp() - Mexican CURP (18 chars with checksum)
  • 🇲🇽 rfc() / mexicanRfc() - Mexican RFC (12-13 chars)
  • 🇧🇷 cpf() / brazilianCpf() - Brazilian CPF (11 digits, Mod 11)
  • 🇧🇷 cnpj() / brazilianCnpj() - Brazilian CNPJ (14 digits, Mod 11)
  • 🇦🇷 argentineDni() - Argentine DNI (7-8 digits)
  • 🇦🇷 cuit() / cuil() / argentineCuit() - Argentine CUIT/CUIL (Mod 11)
  • 🇨🇱 rut() / chileanRut() - Chilean RUT (Mod 11 with K)
  • 🇨🇦 sin() / canadianSin() - Canadian SIN (Luhn algorithm)
  • 🇨🇴 colombianCc() - Colombian Cédula de Ciudadanía
  • 🇪🇨 ecuadorianCedula() - Ecuadorian Cédula (Mod 10)

Asia & Oceania (5 validators):

  • 🇨🇳 chineseId() - Chinese ID (18 digits with date and Mod 11)
  • 🇮🇳 aadhaar() / indianAadhaar() - Indian Aadhaar (Verhoeff algorithm)
  • 🇮🇳 pan() / indianPan() - Indian PAN (10 chars)
  • 🇦🇺 tfn() / australianTfn() - Australian TFN (Mod 11)
  • 🇸🇬 nric() / singaporeNric() - Singapore NRIC/FIN

Added - Generic National ID Validator #

  • nationalId(NationalIdType type) - Generic validator using enum
  • NationalIdType enum with 26 document types
  • NationalIdType.fromCountry(countryCode, docType) - Dynamic type resolution

Added - Checksum Algorithms Mixin #

  • ChecksumAlgorithms mixin with reusable algorithms:
    • luhnCheck() - Luhn/Mod 10 algorithm
    • mod11Checksum() - Mod 11 with custom weights
    • mod97() - Mod 97 algorithm (IBAN-style)
    • verhoeffCheck() - Verhoeff algorithm

Added - Additional Validators #

  • hexColor() - Validates hexadecimal color strings (#RGB, #RRGGBB, #AARRGGBB)
    • Option requireHash to require # prefix
    • Option allowAlpha to allow 8-digit colors with alpha channel
  • jwt() - Validates JWT (JSON Web Token) format
    • Validates 3-part structure (header.payload.signature)
    • Validates base64url encoding
    • Validates header contains "alg" field

Added - Tests #

  • 17 new tests for DateTime validators
  • 45 new tests for identity validators
  • 12 new tests for HexColor and JWT validators
  • Total new tests: 74

Statistics #

  • Total validators: 58+ (30 basic + 10 advanced + 12 DateTime + 26 identity)
  • Total countries with identity support: 18
  • Total tests: 215+ (all passing)

0.3.0 - 2026-01-26 #

Added - Isolate Validation (Parallel Processing) #

  • Isolate validation support: Execute validations in separate isolates using Isolate.run
  • New methods for parallel validation:
    • validateIsolate(instance): Validate a single instance in an isolate
    • validateManyIsolate(instances): Validate multiple instances in an isolate (batch processing)
    • validateAsyncIsolate(instance): Async validation in an isolate
  • No dependencies required: Uses Dart SDK 2.19+ built-in Isolate.run
  • Universal support: Works in Flutter apps, backend Dart, CLI tools, and web
  • Performance optimized: Perfect for batch processing (1000+ objects) and computationally expensive validations
  • 11 new tests: Complete test coverage for isolate validation

Technical Details #

  • Requires Dart SDK 2.19 or higher
  • Zero additional dependencies (uses dart:isolate)
  • Overhead: ~5-10ms per isolate creation
  • Ideal for:
    • CSV/Excel import (1000+ records)
    • Background batch processing
    • Complex validations (50+ rules)
    • Flutter apps that cannot block UI
    • Backend data processing

0.2.0 - 2026-01-25 #

Added - Advanced Validators #

  • IP Address validation: IPv4, IPv6, or both formats
  • MAC Address validation: Supports colon, hyphen, and no-separator formats
  • GPS Coordinates validation: Latitude (-90 to 90) and Longitude (-180 to 180)
  • Credit Card validation: Luhn algorithm, 13-19 digits, supports spaces/hyphens
  • IBAN validation: Full Mod-97 algorithm, 52 countries supported
  • ISBN validation: ISBN-10 and ISBN-13 with checksum validation
  • UUID validation: Versions 1, 2, 3, 4, and 5
  • Postal Code validation: 129 countries worldwide organized by region
    • América del Norte (12): US, CA, MX, CR, PA, GT, SV, HN, NI, CU, DO, PR
    • América del Sur (10): BR, AR, CL, CO, PE, VE, EC, BO, PY, UY
    • Europa Occidental (18): GB, FR, DE, ES, IT, NL, BE, CH, AT, PT, IE, LU, MC, AD, SM, LI, VA, GI
    • Europa Nórdica (5): SE, NO, DK, FI, IS, FO, GL
    • Europa Oriental (25): PL, CZ, SK, HU, RO, BG, HR, SI, EE, LV, LT, UA, BY, MD, RS, BA, MK, AL, GR, CY, MT, ME, XK
    • Rusia y Asia Central (5): RU, KZ, AM, AZ, GE
    • Asia Oriental (6): JP, CN, KR, TW, HK, MO
    • Sudeste Asiático (10): TH, VN, MY, SG, ID, PH, MM, KH, LA, BN
    • Asia del Sur (7): IN, PK, BD, LK, NP, BT, MV
    • Oriente Medio (13): TR, IL, SA, AE, QA, KW, BH, OM, JO, LB, IQ, IR, PS
    • África (13): ZA, EG, MA, DZ, TN, LY, KE, NG, ET, GH, MR, MU, LC
    • Oceanía (5): AU, NZ, PG, FJ, VG

Added - Inline Validation Extensions #

  • All 8 advanced validators available as inline extensions
  • .validateIPv4, .validateIPv6, .validateMACAddress
  • .validateLatitude, .validateLongitude
  • .validateCreditCard, .validateIBAN, .validateISBN, .validateUUID

Added - Examples and Tests #

  • New example: advanced_validation_example.dart demonstrating all advanced validators
  • 39 new tests for advanced validators (Validator Pattern + Inline)
  • Total tests: 104 (all passing ✅)

Statistics #

  • Total validators: 28 (20 basic + 8 advanced)
  • Total tests: 104 (100% passing)
  • Total lines of code: ~2,762 lines
  • Code coverage: 100% on core functionality

0.1.0 #

Initial Release #

Core Features

  • ✅ Fluent API for building validation rules
  • ✅ Strong typing and null-safety support
  • ✅ Comprehensive built-in validators

String Validators

  • notEmpty() - Ensures string is not empty
  • notNull() - Ensures value is not null
  • length(min, max) - Validates string length range
  • minLength(length) - Validates minimum length
  • maxLength(length) - Validates maximum length
  • exactLength(length) - Validates exact length
  • emailAddress() - Validates email format
  • url() - Validates URL format
  • matches(regex) - Validates against regex pattern
  • alpha() - Validates alphabetic characters only
  • alphanumeric() - Validates alphanumeric characters only

Number Validators

  • greaterThan(value) - Value must be greater than specified
  • greaterThanOrEqual(value) - Value must be greater than or equal
  • lessThan(value) - Value must be less than specified
  • lessThanOrEqual(value) - Value must be less than or equal
  • inclusiveBetween(from, to) - Value must be within inclusive range
  • exclusiveBetween(from, to) - Value must be within exclusive range

Comparison Validators

  • equal(value) - Value must equal specified value
  • notEqual(value) - Value must not equal specified value
  • equalTo(property) - Value must equal another property
  • notEqualTo(property) - Value must not equal another property

Collection Validators

  • notEmpty() - Collection must not be empty
  • minLength(length) - Collection must have minimum items
  • maxLength(length) - Collection must have maximum items
  • exactLength(length) - Collection must have exact number of items

Custom Validators

  • must(predicate, message) - Custom synchronous validation
  • mustWith(predicate, message) - Custom validation with object context
  • mustAsync(predicate, message) - Custom asynchronous validation
  • mustAsyncWith(predicate, message) - Custom async validation with context

Advanced Features

  • Conditional validation with when() and unless()
  • Custom error messages with withMessage()
  • Cascade modes (continue or stop on first failure)
  • Nested object validation with ruleForEach()
  • Asynchronous validation support
  • Rich validation results with detailed error information

Documentation

  • Comprehensive README with examples
  • API documentation with dartdoc comments
  • Example applications demonstrating:
    • Basic validation
    • Complex nested validation
    • Asynchronous validation
    • Flutter integration

Testing

  • 47+ unit tests covering all validators
  • Integration tests for complex scenarios
  • 100% code coverage on core functionality
2
likes
160
points
124
downloads

Publisher

unverified uploader

Weekly Downloads

A simple and flexible validation library for Dart that provides validators for common use cases.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on just_validation