Skip to content

Latest commit

 

History

History
44 lines (36 loc) · 934 Bytes

ranges.md

File metadata and controls

44 lines (36 loc) · 934 Bytes

Overridable values

Configurator part

Since version 4.1 is possible to define a range of values available for a certain properties.

use Sensorario\Resources\Configurator;
use Sensorario\Resources\Container;

$configurator = new Configurator(
   'foo',
   new Container([
       'resources' => [
           'foo' => [
               'constraints' => [
                   'allowedRanges' => [
                       'age' => [
                            'more_than' => 3,
                            'less_than' => 42,
                       ],
                   ],
                   'allowed' => [
                       'age'
                   ],
               ],
           ],
       ],
   ])
);

Usages

Trying to create a resource with 2, that is a value not in range 3-42, an exception will be thrown.

use Sensorario\Resources\Resource;

Resource::box(
   [ 'age' => 2 ],
   $configurator
);