From 8459bebceb9533948193774371cbd9fd571b78ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 16 Oct 2019 09:48:31 +0200 Subject: Cowboy 2.7.0 --- docs/en/cowboy/2.3/guide/constraints/index.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'docs/en/cowboy/2.3/guide/constraints') diff --git a/docs/en/cowboy/2.3/guide/constraints/index.html b/docs/en/cowboy/2.3/guide/constraints/index.html index 91afdfc5..4dae6afb 100644 --- a/docs/en/cowboy/2.3/guide/constraints/index.html +++ b/docs/en/cowboy/2.3/guide/constraints/index.html @@ -71,7 +71,7 @@

Constraints for each field are provided as an ordered list of atoms or funs to apply. Built-in constraints are provided as atoms, while custom constraints are provided as funs.

When multiple constraints are provided, they are applied in the order given. If the value has been modified by a constraint then the next one receives the new value.

For example, the following constraints will first validate and convert the field my_value to an integer, and then check that the integer is positive:

-
@@ -85,7 +85,7 @@ http://www.gnu.org/software/src-highlite -->

We ignore the first fun argument in this snippet. We shouldn't. We will simply learn what it is later in this chapter.

When there's only one constraint, it can be provided directly without wrapping it into a list:

-
@@ -107,7 +107,7 @@ http://www.gnu.org/software/src-highlite -->

Custom constraints

Custom constraints are specified as a fun. This fun takes two arguments. The first argument indicates the operation to be performed, and the second is the value. What the value is and what must be returned depends on the operation.

Cowboy currently defines three operations. The operation used for validating and converting user input is the forward operation.

-
@@ -120,7 +120,7 @@ http://www.gnu.org/software/src-highlite -->

The value must be returned even if it is not converted by the constraint.

The reverse operation does the opposite: it takes a converted value and changes it back to what the user input would have been.

-
@@ -132,7 +132,7 @@ http://www.gnu.org/software/src-highlite --> end;

Finally, the format_error operation takes an error returned by any other operation and returns a formatted human-readable error message.

-
@@ -198,6 +198,8 @@ http://www.gnu.org/software/src-highlite --> +
  • 2.7
  • +
  • 2.6
  • 2.5
  • -- cgit v1.2.3