Ejemplo n.º 1
0
 public function testDate()
 {
     $form = new Validator(['birthday' => ['date']]);
     $this->assertTrue($form->validate(['birthday' => '2000-01-01']));
     $this->assertFalse($form->validate(['birthday' => '01/01/2001']));
     $form = new Validator(['birthday' => ['date' => null]]);
     $this->assertTrue($form->validate(['birthday' => '2000-01-01']));
     $this->assertTrue($form->validate(['birthday' => '01/01/2001']));
 }
Ejemplo n.º 2
0
<?php

require 'vendor/autoload.php';
// form validator with json object
use Form\Validator;
$jsonObject = json_encode(['username' => 'nandeesh', 'email' => '*****@*****.**', 'password' => 'nandeesh', 'confirm-password' => 'nandeesh']);
$rules = ['username' => 'required|Minlength:4', 'email' => 'required|email', 'password' => 'required', 'confirm-password' => 'required|same:password'];
$validator = new Validator($rules, $jsonObject);
echo 'Result : ' . $validator->isValid();
Ejemplo n.º 3
0
 private function fails($rules, $object)
 {
     $validator = new Validator($rules, $object);
     $this->assertFalse($validator->isValid());
 }