Debian Codegraph @

doc/src/manual/cowboy_constraints.int.asciidoc

raw
1 = cowboy_constraints:int(3)
2
3 == Name
4
5 cowboy_constraints:int - Integer constraint
6
7 == Description
8
9 Constraint functions implement a number of different operations.
10
11 [source,erlang]
12 ----
13 int(forward, Bin) -> {ok, Int} | {error, not_an_integer}
14
15 Bin :: binary()
16 Int :: integer()
17 ----
18
19 Validate and convert the text representation of an integer.
20
21 [source,erlang]
22 ----
23 int(reverse, Int) -> {ok, Bin} | {error, not_an_integer}
24 ----
25
26 Convert an integer back to its text representation.
27
28 [source,erlang]
29 ----
30 int(format_error, Error) -> HumanReadable
31
32 Error :: {not_an_integer, Bin | Int}
33 HumanReadable :: iolist()
34 ----
35
36 Generate a human-readable error message.
37
38 == Arguments
39
40 Arguments vary depending on the operation. Constraint
41 functions always take the operation type as first argument,
42 and the value as second argument.
43
44 == Return value
45
46 The return value varies depending on the operation.
47
48 == Changelog
49
50 * *2.0*: Interface modified to allow for a variety of operations.
51 * *1.0*: Constraint introduced.
52
53 == Examples
54
55 This function is not meant to be called directly.
56
57 == See also
58
59 link:man:cowboy_constraints(3)[cowboy_constraints(3)],
60 link:man:cowboy_constraints:nonempty(3)[cowboy_constraints:nonempty(3)],
61 link:man:cowboy_constraints:from_fun(3)[cowboy_constraints:from_fun(3)],
62 link:man:cowboy_router(3)[cowboy_router(3)],
63 link:man:cowboy_req:match_cookies(3)[cowboy_req:match_cookies(3)],
64 link:man:cowboy_req:match_qs(3)[cowboy_req:match_qs(3)]