ConstraintValidator
public protocol ConstraintValidator
A common protocol for all Constraint
validators.
-
Validates a primitive
Encodable
value against aConstraint
with default parameters.Throws
AValidator.Error
if the value is not of primitive type or aConstraintViolation
if the value doesn’t satisfy aConstraint
.Declaration
Swift
func validate(_ value: Encodable?) throws
Parameters
value
A primitive
Encodable
value to be validated. -
Validates a primitive
Encodable
value against aConstraint
with custom parameters.Throws
AValidator.Error
if the value is not of primitive type or aConstraintViolation
if the value doesn’t satisfy aConstraint
.Declaration
Swift
func validate(_ value: Encodable?, against constraint: Constraint) throws
Parameters
value
A primitive
Encodable
value to be validated.constraint
An instance of
Constraint
with custom parameters.