Skip to content

Instance Method

require(_:as:)

Grabs the named parameter from the parameter bag, casting it to a LosslessStringConvertible type. If the parameter does not exist, Abort(.internalServerError) is thrown. If the parameter value cannot be converted to the required type, Abort(.unprocessableEntity) is thrown.
func require<T>(_ name: String, as type: T.Type = T.self) throws -> T where T : LosslessStringConvertible

Parameters

name

The name of the parameter.

type

The required parameter value type.