feat: Updates to use swift-validations for database.
All checks were successful
CI / Linux Tests (push) Successful in 6m28s
All checks were successful
CI / Linux Tests (push) Successful in 6m28s
This commit is contained in:
20
Sources/DatabaseClient/Internal/User+validation.swift
Normal file
20
Sources/DatabaseClient/Internal/User+validation.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
import ManualDCore
|
||||
import Validations
|
||||
|
||||
// Declaring this in seperate file because some Vapor imports
|
||||
// have same name's and this was easiest solution.
|
||||
extension User.Create: Validatable {
|
||||
public var body: some Validation<Self> {
|
||||
Validator.accumulating {
|
||||
Validator.validate(\.email, with: .email())
|
||||
.errorLabel("Email", inline: true)
|
||||
|
||||
Validator.validate(\.password.count, with: .greaterThanOrEquals(8))
|
||||
.errorLabel("Password Count", inline: true)
|
||||
|
||||
Validator.validate(\.confirmPassword, with: .equals(password))
|
||||
.mapError(ValidationError("Confirm password does not match."))
|
||||
.errorLabel("Confirm Password", inline: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user