- Input validator for Swift
- 94% Code Coverage
- Declarative Validator
- Functional Programming
let numberValidator = Validator<Int>().lesserThan(value: 150).greaterOrEqualsThan(value: 10)
let result = try numberValidator.validate(value: 50)
let emailValidator = Validator<String>().notEmpty().maxLength(length: 55).isEmailAddress()
let result = try emailValidator.validate(value: "yourmail@mail.com")
let emailValidator = Validator<String>().notEmpty().maxLength(length: 55).isEmailAddress()
let result = emailValidator.validateAsPublisher(value: "yourmail@mail.com")
Validator has an add method where you set a validation rule
func add(rule: @escaping (Input) throws -> Bool) -> Validator<Input>
See how it works:
let emailValidator = Validator<String>().notEmpty().maxLength(length: 55).isEmailAddress().add { string in
return string.count == 25
}
let result = try emailValidator.validate(value: "yourmail@mail.com")
- iOS 13.0+
- MacOS 10.15+
- Xcode 12.0.1+
- Swift 5+
QHValidator has support for SPM, you just need to go to Xcode in the menu File/Swift Packages/Add package dependency and you select the version of QHValidator.