ConstraintValidator

public protocol ConstraintValidator

A common protocol for all Constraint validators.

  • Validates a primitive Encodable value against a Constraintwith default parameters.

    Throws

    A Validator.Error if the value is not of primitive type or a ConstraintViolation if the value doesn’t satisfy a Constraint.

    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

    A Validator.Error if the value is not of primitive type or a ConstraintViolation if the value doesn’t satisfy a Constraint.

    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.