A lightweight, fluent validation library for Swift — chainable rules, localized error messages, zero dependencies.
📖 Full documentation & rules reference
- Fluent, chainable schemas — describe every field's rules in one readable expression
- Zero dependencies — pure Swift, Foundation only
- Localized out of the box — error messages ship in English, Arabic, Spanish, and French
- 20+ built-in rules — email, phone, credit card (Luhn), IBAN, password strength, dates, regex, file size, and more
- Works anywhere — validate a decoded JSON payload, a form dictionary, or a view model's fields the same way
dependencies: [
.package(url: "https://github.com/Alhiane/ValidatorKit.git", from: "1.0.0-beta")
]import ValidatorKit
let schema = ValidationSchema()
.field("email").required().email()
.field("password").required().passwordStrength(minLength: 8, requireDigit: true, requireSymbol: true)
.field("age").required().greaterThan(18)
.ready()
let result = schema.validate([
"email": "not-an-email",
"password": "short",
"age": 16
])
result.isValid // false
result.errors["email"] // ["Please enter a valid email address."]Custom validation when a built-in rule isn't enough:
.field("username").required().custom(message: "Must be lowercase, no spaces") { value in
guard let username = value as? String else { return false }
return username == username.lowercased() && !username.contains(" ")
}For the complete list of rules, localization details, and more examples, see the full docs.
Issues and PRs are welcome — see CONTRIBUTING.md for the development and release workflow.
MIT — see LICENSE.