Created
February 10, 2016 10:00
-
-
Save amodef/e61fa7e3131175a707ea to your computer and use it in GitHub Desktop.
Investigating a possible Valitron bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Valitron\Validator; | |
function validate($data, $rules) | |
{ | |
$v = new Validator($data); | |
$v->rules($rules); | |
return $v->validate(); | |
} | |
$data = ['foo' => '', 'bar' => '', 'baz' => 'test']; | |
$rules = ['required' => 'foo']; | |
if (validate($data, $rules)) { | |
echo "It passes" . PHP_EOL; | |
} else { | |
echo "It's blocked" . PHP_EOL; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Valitron\Validator; | |
function validate($data, $rules) | |
{ | |
$v = new Validator($data); | |
$v->rules($rules); | |
return $v->validate(); | |
} | |
$data = ['foo' => '', 'bar' => '', 'baz' => 'test']; | |
$rules = ['required' => 'foo']; | |
$rules = ['required' => 'baz']; | |
if (validate($data, $rules)) { | |
echo "It passes" . PHP_EOL; | |
} else { | |
echo "It's blocked" . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment