aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/cowboy_constraints.int.asciidoc
blob: 28855a48023d5ca076f7f35059b10f964f62cb72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
= cowboy_constraints:int(3)

== Name

cowboy_constraints:int - Integer constraint

== Description

Constraint functions implement a number of different operations.

[source,erlang]
----
int(forward, Bin) -> {ok, Int} | {error, not_an_integer}

Bin :: binary()
Int :: integer()
----

Validate and convert the text representation of an integer.

[source,erlang]
----
int(reverse, Int) -> {ok, Bin} | {error, not_an_integer}
----

Convert an integer back to its text representation.

[source,erlang]
----
int(format_error, Error) -> HumanReadable

Error         :: {not_an_integer, Bin | Int}
HumanReadable :: iolist()
----

Generate a human-readable error message.

== Arguments

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.

== Changelog

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

== Examples

This function is not meant to be called directly.

== See also

link:man:cowboy_constraints(3)[cowboy_constraints(3)],
link:man:cowboy_constraints:nonempty(3)[cowboy_constraints:nonempty(3)],
link:man:cowboy_router(3)[cowboy_router(3)],
link:man:cowboy_req:match_cookies(3)[cowboy_req:match_cookies(3)],
link:man:cowboy_req:match_qs(3)[cowboy_req:match_qs(3)]