Skip to content

Commit fc49d93

Browse files
committed
Documentation of the new numerical type handling
1 parent 9118861 commit fc49d93

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

components/config/definition.rst

+39-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Variable nodes
7474

7575
A tree contains node definitions which can be layed out in a semantic way.
7676
This means, using indentation and the fluent notation, it is possible to
77-
reflect the real structure of the configuration values::
77+
reflect the real structure of the configuration values:
7878

7979
$rootNode
8080
->children()
@@ -91,6 +91,44 @@ The root node itself is an array node, and has children, like the boolean
9191
node ``auto_connect`` and the scalar node ``default_connection``. In general:
9292
after defining a node, a call to ``end()`` takes you one step up in the hierarchy.
9393

94+
Node type
95+
~~~~~~~~~
96+
97+
It is possible to validate the type of a provided value by using appropriate node
98+
definition. Node type are available for:
99+
100+
* variable (no validation)
101+
* scalar
102+
* boolean
103+
* integer
104+
* float
105+
* array
106+
* enum
107+
108+
and are created with ``node($name, $type)`` or there associated shortcuts ``xxxxNode($name)`` method.
109+
110+
Numeric node constraints
111+
~~~~~~~~~~~~~~~~~~~~~~~~
112+
113+
Numeric node (float and integer) provide two extra constraints min() and max() allowing to validate the value:
114+
115+
.. code-block:: php
116+
117+
$rootNode
118+
->children()
119+
->integerNode('positive_value')
120+
->min(0)
121+
->end()
122+
->floatNode('big_value')
123+
->max(5E45)
124+
->end()
125+
->integerNode('value_inside_a_range')
126+
->min(-50)->max(50)
127+
->end()
128+
->end()
129+
;
130+
131+
94132
Array nodes
95133
~~~~~~~~~~~
96134

0 commit comments

Comments
 (0)