This is a major release. It contains breaking changes: see Removed (CocoaPods) and Behavior
change (regex full matching) below.
Added
- Array based
validate(with rules: [ValidationRule], shouldCombineErrorMessages:message:)overload on the.nzvString namespace, so pre-built rule arrays (for example vended by a use case) can be validated without a variadic call. Error messages are not merged by default. IsURLValidationRuleplus.nzv.isURL()and the containerisURL()method, validating that a string can be interpreted as a URL host.OrValidationRule(any-of) andNotValidationRule(negation) combinators, plus containerany(of:)andnot(_:)conveniences.Sendableconformance across the public API (ValidationResult,ValidationRule, and the rules) for use under Swift 6 strict concurrency, andEquatableconformance onValidationResult.- Rewritten README that documents the real
.nzvAPI with working installation, quick start, rule table, and usage examples. - Swift Testing target (
NerdzValidationTests) covering every rule, the rules container, the result type, and the.nzvString extension (around 99% line coverage). - DocC documentation catalog with a landing page, a Getting Started article, and reference docs on all public symbols.
Changed
RegexValidationRule(and itsIsEmail/IsPhone/IsURLrelatives) now compile their regular expression once at initialization instead of on everyvalidate(_:)call.ValidationRulenow refinesSendable. Custom rules conforming to it must also beSendable(a pure predicate rule already is).ByClosureValidationRule's closure is now@Sendable.Package.swiftswift-tools-versionraised from 5.3 to 5.9 to support Swift Testing. The runtime deployment target is unchanged (tests are not shipped). Building the package now requires Xcode 15 or later.
Removed
- CocoaPods support. The podspec has been deleted and the library is now distributed through Swift Package Manager only. Projects that installed NerdzValidation with CocoaPods must migrate to SPM.
Fixed
IsPhoneValidationRulereturned "Invalid email address" as its default failure message. It now returns "Invalid phone number".CombinedValidationRuleevaluated each rule twice when a container level message was set. Rules are now evaluated exactly once. Output is unchanged.RegexValidationRuletreated a string as valid when the pattern produced exactly one match anywhere in it. It now requires the pattern to match the entire string.
Behavior change
- Because of the
RegexValidationRulefix, unanchored patterns (including the built in email rule) now reject strings that only partially match. For example "hello a@b.io there" is no longer considered a valid email. Anchored patterns (such as the built in phone rule) are unaffected.