Commit f8e63f31 by Taylor Otwell

adding validator tests.

parent 8bd6d346
......@@ -208,7 +208,7 @@ class Validator {
*/
protected function validate_required($attribute, $value)
{
return (is_null($value) or (is_string($value) and trim($value) === ''));
return ! (is_null($value) or (is_string($value) and trim($value) === ''));
}
/**
......
<?php
use Laravel\Validation\Validator;
class ValidatorTest extends PHPUnit_Framework_TestCase {
public function test_simple_group_of_validations()
{
$rules = array(
'email' => 'required|email',
'password' => 'required|confirmed|min:6',
'name' => 'required|alpha',
);
$attributes = array(
'email' => 'taylorotwell',
'password' => 'something',
'password_confirmation' => 'something',
'name' => 'taylor5',
);
$messages = array('name_alpha' => 'The name must be alphabetic!');
$validator = Validator::make($attributes, $rules, $messages);
$this->assertFalse($validator->valid());
$this->assertFalse($validator->errors->has('password'));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment