cowboy_constraints:nonempty - Non-empty constraint


Constraint functions implement a number of different operations.

nonempty(forward | reverse, <<>>) -> {error, empty}

Reject empty values.

nonempty(forward | reverse, Bin) -> {ok, Bin}

Bin :: binary()

Accept any other binary values.

nonempty(format_error, Error) -> HumanReadable

Error         :: {empty, Bin}
HumanReadable :: iolist()

Generate a human-readable error message.


Arguments vary depending on the operation. Constraint functions always take the operation type as first argument, and the value as second argument.

Return value

The return value varies depending on the operation.


  • 2.0: Interface modified to allow for a variety of operations.
  • 1.0: Constraint introduced.


This function is not meant to be called directly.

See also

cowboy_constraints(3), cowboy_constraints:int(3), cowboy_router(3), cowboy_req:match_cookies(3), cowboy_req:match_qs(3)

Cowboy 2.7 Function Reference


Version select

Like my work? Donate!

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and is fantastic:

Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.