Cake\ElasticSearch\Marshaller::_validate PHP Method

_validate() protected method

Returns the validation errors for a data set based on the passed options
protected _validate ( array $data, array $options, boolean $isNew ) : array
$data array The data to validate.
$options array The options passed to this marshaller.
$isNew boolean Whether it is a new entity or one to be updated.
return array The list of validation errors.
    protected function _validate($data, $options, $isNew)
    {
        if (!$options['validate']) {
            return [];
        }
        if ($options['validate'] === true) {
            $options['validate'] = $this->type->validator('default');
        }
        if (is_string($options['validate'])) {
            $options['validate'] = $this->type->validator($options['validate']);
        }
        if (!is_object($options['validate'])) {
            throw new RuntimeException(sprintf('validate must be a boolean, a string or an object. Got %s.', gettype($options['validate'])));
        }
        return $options['validate']->errors($data, $isNew);
    }