Checks and sets items specification.

@param bool|\Mcustiel\SimpleRequest\Interfaces\ValidatorInterface $specification

@throws \Mcustiel\SimpleRequest\Exception\UnspecifiedValidatorException
356337
private function setAdditionalProperties($specification)
    {
        if (is_bool($specification)) {
            $this->additionalProperties = $specification;
        } else {
            $this->additionalProperties = $this->checkIfAnnotationAndReturnObject($specification);
        }
    }
365749
protected function _setValidator($validator)
    {
        if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
        }

        $this->validator = $validator;
    }
409755
protected function validate($field, $value, array $item_rules)
    {
        $this->preserveItem($field, $value, $item_rules);
        
        if (! array_key_exists('required', $item_rules)) {
            $item_rules['required'] = false;
        }
        
        if ($item_rules['required'] || $this->required($field, $value, $item_rules['required'])) {
            foreach ($item_rules as $rule => $satisfier) {
                $this->validateRule($this, $field, $value, $rule, $satisfier);
            }
        }
    }
1186529
protected function validateConfig(SettingsInterface $settings)
    {
        foreach ($this->getRequiredSettings() as $required_setting) {
            if (is_null($settings->getValues($required_setting))) {
                throw new ConfigError(
                    "Missing mandatory setting '" . $required_setting . "' for config."
                );
            }
        }
    }
737716
final protected function assertInterfaceSatisfiesSpecification(callable $specification, string $interfaceName, string $message = ''): void
    {
        $this->assertInterfaceExists($interfaceName);

        self::assertTrue($specification($interfaceName), \sprintf(
            '' !== $message ? $message : 'Failed asserting that interface "%s" satisfies a specification.',
            $interfaceName
        ));
    }
81524
private function validateAttributes($mandatory = [], $notAvailable = [])
	{
		foreach ($mandatory as $item) {
			if (is_array($item)) {
				$count = 0;

				foreach ($item as $subItem) {
					$resolvedAttribute = $this->resolveAttributeFromMapping($subItem);

					if ($resolvedAttribute !== NULL) {
						$count++;
					}
				}

				if ($count != 1) {
					throw new InvalidAttributeStatusException(join('" or "', $item), 'mandatory');
				}
			} else {
				$resolvedAttribute = $this->resolveAttributeFromMapping($item);

				if ($resolvedAttribute === NULL) {
					throw new InvalidAttributeStatusException($item, 'mandatory');
				}
			}
		}

		foreach ($notAvailable as $item) {
			$resolvedAttribute = $this->resolveAttributeFromMapping($item);

			if ($resolvedAttribute !== NULL) {
				throw new InvalidAttributeStatusException($item, 'not available');
			}
		}
	}
121373
protected function _setSpec($spec)
    {
        if (!is_null($spec)) {
            $spec = $this->_normalizeIterable($spec);
        }

        $this->spec = $spec;
    }
1225529
public function setSpecification($specification = null)
    {
        if (!is_int($specification) || $specification < 0) {
            throw new UnspecifiedValidatorException(
                'Size validator is being initialized without a valid number'
            );
        }
        $this->size = $specification;
    }
82511
public function setSpecification($specification = null)
    {
        if (empty($specification) || !is_numeric($specification) || $specification <= 0) {
            throw new UnspecifiedValidatorException(
                'The validator MultipleOf is being initialized without a valid number'
            );
        }
        $this->number = $specification;
    }
983503
public function validate(TransientVarsInterface $transientVars, array $args = [], PropertySetInterface $ps)
    {
        $serviceUtil = $this->getServiceUtil();
        $service = $this->getService();
        $metadata = $this->getMetadata();
        $listArguments = $serviceUtil->buildArgumentsForService($service, $metadata, $transientVars, $args);

        call_user_func_array($service, $listArguments);
    }
1086803
public function add(SpecificationContract $specification)
    {
        $this->items->put($specification->uid(), $specification);

        return $this;
    }
1147946
public function validateValue($value)
    {
        if (!$value instanceof MoneyInterface) {
            throw new Exception\InvalidArgumentException(
                sprintf(
                    'Value of type "%s" is invalid for %s; must implement "%s"',
                    is_object($value) ? get_class($value) : gettype($value),
                    get_class($this),
                    MoneyInterface::class
                )
            );
        }
    }
216844
public function setSpecification($specification = null)
    {
        $this->checkSpecificationIsArray($specification);

        $this->initItems($specification);
        $this->initAdditionalItems($specification);
    }
1035978
public function with($value): ValidableInterface
    {
        parent::with($value);
        
        if (false === ($value instanceof EntityInterface)) {
            throw new ValidatorException(sprintf('Validator accept only (%s) objects', EntityInterface::class));
        }
        
        return $this;
    }
94170
private function initProperties(array $specification)
    {
        if (isset($specification[self::PROPERTIES_INDEX])) {
            $this->setProperties($specification[self::PROPERTIES_INDEX]);
        }
    }
1198571
private function validateInput(InputInterface $input)
    {
        if (!$input->getArgument('target')) {
            // if no target is passed, there can be no properties or methods
            foreach (['properties', 'methods', 'no-inherit'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense without a specified target');
                }
            }

            foreach (['globals', 'vars', 'constants', 'functions', 'classes', 'interfaces', 'traits'] as $option) {
                if ($input->getOption($option)) {
                    return;
                }
            }

            // default to --vars if no other options are passed
            $input->setOption('vars', true);
        } else {
            // if a target is passed, classes, functions, etc don't make sense
            foreach (['vars', 'globals', 'functions', 'classes', 'interfaces', 'traits'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense with a specified target');
                }
            }

            foreach (['constants', 'properties', 'methods'] as $option) {
                if ($input->getOption($option)) {
                    return;
                }
            }

            // default to --constants --properties --methods if no other options are passed
            $input->setOption('constants',  true);
            $input->setOption('properties', true);
            $input->setOption('methods',    true);
        }
    }
1100464
public function validate($item)
    {
        if (!$item) {
            $item = new \stdClass();
        }
        $validator = $this->getValidator();

        try {
            $validator->assert($item);
            return $this->populate($item);
        } catch (Exception $e) {
            throw new ConfigValidationFailedException(get_class($this), '', $e);
        }
    }