Skip to content

Instantly share code, notes, and snippets.

@amodef
Created February 10, 2016 10:00
Show Gist options
  • Save amodef/e61fa7e3131175a707ea to your computer and use it in GitHub Desktop.
Save amodef/e61fa7e3131175a707ea to your computer and use it in GitHub Desktop.
Investigating a possible Valitron bug
<?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;
}
<?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