ValidatedPropertyKit v0.0.2 Release Notes
Release Date: 2019-07-10 // over 4 years ago-
🍱 Error Handling 🕵️♂️
Each property that is declared with the
@Validated
attribute can make use of advanced functions and properties from theValidated
Property Wrapper itself via the$
notation prefix.Beside doing a simple
nil
check on your@Validated
property to ensure if the value is valid or not you can access thevalidatedValue
orvalidationError
property to retrieve theValidationError
or the valid value.@Validated(.nonEmpty)var username: String?// Switch on `validatedValue`switch $username.validatedValue {case .success(let value):// Value is valid ✅breakcase .failure(let validationError):// Value is invalid ⛔️break}// Or unwrap the `validationError`if let validationError = $username.validationError { // Value is invalid ⛔️} else { // Value is valid ✅}