ValidatedPropertyKit v0.0.2 Release Notes

Release Date: 2019-07-10 // over 3 years ago
  • 🍱 Error Handling 🕵️‍♂️

    Each property that is declared with the @Validated attribute can make use of advanced functions and properties from the Validated 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 the validatedValue or validationError property to retrieve the ValidationError 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 ✅}