Skip to content

Releases: SvenTiigi/ValidatedPropertyKit

Version 0.0.7

30 Dec 20:24
Compare
Choose a tag to compare

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

30 Dec 09:55
Compare
Choose a tag to compare

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

17 Jan 22:11
Compare
Choose a tag to compare

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

07 Feb 07:29
Compare
Choose a tag to compare

Updated @Validated initializer to accept a initial value

Version 0.0.3

26 Sep 16:41
Compare
Choose a tag to compare

Improved Package.swift

Updated Swift toolchain to 5.0 and declared platforms

Version 0.0.2

10 Jul 15:22
Compare
Choose a tag to compare

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 🙌

25 Jun 17:27
Compare
Choose a tag to compare

This is the initial release of ValidatedPropertyKit