/** * @expectedException \UnexpectedValueException * @expectedExceptionMessage Validator name must be a string, object given */ public function testIsNonStringValidatorNameValid() { $v = new Validator(); $rules = [['first_name', new \stdClass()]]; $v->setRules($rules); }
/** * This is fully-working example, showing how to use framework in action. * You can copy the content of this file and use it in a bootstrap script in your project, * or paste it in any other file that can be executed directly from the browser. * But don't try to execute this file itself :) */ use valify\Validator; require 'vendor/autoload.php'; $validator = new Validator(); // require "your/own/path/to/ValidatorClass.php"; $rules = [['username', 'required'], [['username', 'password'], 'string', 'max' => 10], ['email', 'email', 'message' => 'Please provide a valid email'], ['remember_me', 'boolean'], ['file', 'file', 'minSize' => 10000, 'maxFiles' => 2, 'extensions' => ['jpg'], 'checkExtensionByMimeType' => false]]; if (!empty($_POST)) { $data = $_POST; $data['file'] = $_FILES['file']; $isValid = $validator->setRules($rules)->loadData($data)->validate(); } function getValue($val) { return isset($_POST[$val]) ? $_POST[$val] : ''; } ?> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <style> .help-block { color: red; } </style>