protected function _buildValidators() { parent::_buildValidators(); // @see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#user-content-parameterMaxItems // @see http://json-schema.org/latest/json-schema-validation.html#anchor42 if (isset($this->_data->maxItems)) { $maxItems = $this->_data->maxItems; $this->_validators['maxItems'] = $this->ValidatorFactory->buildValidator('Callback', ['message' => 'expected to have maximum ' . $maxItems . ' items', 'callback' => function ($value) use($maxItems) { return !empty($value) && count($value) > $maxItems ? false : true; }]); } // @see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#user-content-parameterMinItems // @see http://json-schema.org/latest/json-schema-validation.html#anchor45 if (isset($this->_data->minItems)) { $minItems = $this->_data->minItems; $this->_validators['minItems'] = $this->ValidatorFactory->buildValidator('Callback', ['message' => 'expected to have minimum ' . $minItems . ' items', 'callback' => function ($value) use($minItems) { return !empty($value) && count($value) < $minItems ? false : true; }]); } // @see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#user-content-parameterUniqueItems // @see http://json-schema.org/latest/json-schema-validation.html#anchor49 if (isset($this->_data->uniqueItems) && $this->_data->uniqueItems) { $this->_validators['uniqueItems'] = $this->ValidatorFactory->buildValidator('Callback', ['message' => 'expected to have unique items', 'callback' => function ($value) { if (!empty($value)) { if (count($value) != count(array_unique($value))) { return false; } } return true; }]); } // NOTE: this will overwrite parent's non multivalue enum validator // @see https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#user-content-parameterEnum // @see http://json-schema.org/latest/json-schema-validation.html#anchor76 if (isset($this->_data->enum)) { $enum = $this->_data->enum; $this->_validators['enum'] = $this->ValidatorFactory->buildValidator('MultiEnum', ['message' => 'expected values to be in', 'enum' => (array) $enum]); } }
protected function _buildFilters() { parent::_buildFilters(); $this->_filters[] = 'realFloat'; }
protected function _buildFilters() { ParameterAbstract::_buildFilters(); $this->_filters[] = 'realInt'; }