phramework's validation library https://phramework.github.io/validate/
Require package using composer
composer require phramework/validaterequire './vendor/autoload.php';
use \Phramework\Validate\IntegerValidator;
$validationModel = new IntegerValidator(-1, 1);
$value = $validationModel->parse('0');
var_dump($value);The above example will output:
int(0)
$validationModel = new ObjectValidator(
(object) [
'name' => new StringValidator(2, 30),
'city' => new StringValidator(2, 30)
],
['name', 'city'], //required properties
false //no additional properties allowed
);
$value = $validationModel->parse((object) [
'name' => 'Xenofon',
'city' => 'Thessaloniki'
]);
print_r($value);The above example will output:
stdClass Object
(
[name] => Xenofon
[city] => Thessaloniki
)
Check wiki for more examples.
composer updatecomposer test
composer lintcomposer docCopyright 2015 - 2016 Xenofon Spafaridis
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.