JuanColilla / ValidationKit

A set of Validators for Strings using Swift's @propertyWrapper feature. This package allows you to validate Strings using regex in order to ensure the texts you are using comply to the format you want.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValidationKit

Swift 5.7 License: MIT

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.

Features

  • Simple and easy-to-use API
  • Customizable validation rules
  • Built-in support for common validation scenarios
  • Supports SwiftUI and Combine

Installation

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
```

Usage

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
```

Contributing

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.

License

ValidationKit is released under the MIT License. See the LICENSE file for more information.

About

A set of Validators for Strings using Swift's @propertyWrapper feature. This package allows you to validate Strings using regex in order to ensure the texts you are using comply to the format you want.


Languages

Language:Swift 100.0%