Releases: SvenTiigi/ValidatedPropertyKit
Releases · SvenTiigi/ValidatedPropertyKit
Version 0.0.7
What's Changed
- Fixed a bug where a property attributed with
@Validated
couldn't be mutated.
Full Changelog: 0.0.6...0.0.7
Version 0.0.6
What's Changed
- Lowered deployment target to iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15
- Support for CocoaPods and Carthage has been removed. Swift Package Manager is now the preferred way of integrating ValidatedPropertyKit to your project.
Full Changelog: 0.0.5...0.0.6
Version 0.0.5
Refactored Architecture
This release contains breaking changes and introduces a more SwiftUI oriented architecture.
struct LoginView: View {
@Validated(!.isEmpty && .isEmail)
var mailAddress = String()
@Validated(.range(8...))
var password = String()
var body: some View {
List {
TextField("E-Mail", text: self.$mailAddress)
TextField("Password", text: self.$password)
Button(
action: {
print("Login", self.mailAddress, self.password)
},
label: {
Text("Submit")
}
)
.validated(
self._mailAddress,
self._password
)
}
}
}
Version 0.0.4
Updated @Validated
initializer to accept a initial value
Version 0.0.3
Improved Package.swift
Updated Swift toolchain to 5.0
and declared platforms
Version 0.0.2
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 ✅
break
case .failure(let validationError):
// Value is invalid ⛔️
break
}
// Or unwrap the `validationError`
if let validationError = $username.validationError {
// Value is invalid ⛔️
} else {
// Value is valid ✅
}
Initial Release 🙌
This is the initial release of ValidatedPropertyKit