Functions

The following functions are available globally.

  • Converts a primitive value to its String representation.

    Declaration

    Swift

    public func primitive(_ value: Any?) -> String?

    Parameters

    value

    A primitive value.

    Return Value

    A String representation of the value or nil if it can’t be convert to String.

  • Converts a primitive value to its String representation or throws a Validator.Error.

    Throws

    A Validator.Error if the value can’t be convert to String.

    Declaration

    Swift

    @discardableResult
    public func assertPrimitive(_ value: Any?) throws -> String

    Parameters

    value

    A primitive value.

    Return Value

    A String representation of the value.

  • Converts a Constraint to a certain concrete type or throws a Validator.Error.

    Throws

    A Validator.Error if the constraint can’t be converted to the certain type.

    Declaration

    Swift

    @discardableResult
    public func assertConstraintType<T>(_ type: T.Type, for constraint: Constraint) throws -> T where T : Constraint

    Parameters

    type

    A concrete type of Constraint to convert to.

    constraint

    A Constraint to be converted.

    Return Value

    A converted concrete type of Constraint.