ValidationKit is a lightweight Swift library for validating strings based on custom validation rules. It uses a property wrapper to make validation simple and easy to integrate into your projects. ValidationKit is compatible with Swift 5.7 and supports various validation types such as email, phone numbers, password, and more.
- Simple and easy-to-use API
- Customizable validation rules
- Built-in support for common validation scenarios
- Supports SwiftUI and Combine
To use ValidationKit in your project, add it as a dependency to your Package.swift file:
```swift dependencies: [ .package(url: "https://github.com/JuanColilla/ValidationKit.git", from: "1.0.0") ] ```
Then, import ValidationKit in the files where you want to use it:
```swift import ValidationKit ```
Declare a property with the @Validated property wrapper and provide the desired validation rules:
```swift @Validated(.notEmpty) var username: String ```
Use the 'validationState' property to check the validation status of the value:
```swift if username.validationState == .valid { print("The username is valid.") } else { print("The username is not valid.") } ```
Combine multiple validation rules for a single property:
```swift @Validated(.email, .notEmpty) var email: String ```
We welcome contributions, suggestions, and bug reports. Please open an issue on the GitHub repository to discuss your ideas or report any issues you encounter.
ValidationKit is released under the MIT License. See the LICENSE file for more information.