Skip to content

Latest commit

 

History

History
50 lines (43 loc) · 809 Bytes

define-allowed-values.md

File metadata and controls

50 lines (43 loc) · 809 Bytes

Allowed values

Class definition

Also could be defined all allowed type for a property

public static function allowedValues()
{
    return [
        'someApiParameter' => [
            'hello',
            'world'
        ],
    ];
}

Configurator class

use sensorario\resources\configurator;
use sensorario\resources\container;
use sensorario\resources\resource;

$configurator = new Configurator(
  'foo',
  new Container(
    'resources' => [
      'foo' => [
        'constraints' => [
          'allowed' => [
            'property_name',
          ],
          'allowedValues' => [
            'property_name' => [
              4,
              7,
            ],
          ],
        ],
      ],
    ]
  )
);

Resource::box([
  'property_name' => 7,
], $configurator);