Esempio n. 1
0
 public function testMultipleLocales()
 {
     $data = '/phone en_US/';
     Catalog::write('runtime', 'validation.phone', 'en_US', $data);
     $data = '/phone en_GB/';
     Catalog::write('runtime', 'validation.phone', 'en_GB', $data);
     Validator::add('phone', array('en_US' => Catalog::read('runtime', 'validation.phone', 'en_US'), 'en_GB' => Catalog::read('runtime', 'validation.phone', 'en_GB')));
     $result = Validator::isPhone('phone en_US', 'en_US');
     $this->assertTrue($result);
     $result = Validator::isPhone('phone en_GB', 'en_GB');
     $this->assertTrue($result);
 }
Esempio n. 2
0
 /**
  * Tests that new formats can be added to existing regex methods using Validator::add().
  */
 public function testAddCustomRegexFormats()
 {
     $this->assertTrue(Validator::isPhone('1234567890'));
     $this->assertTrue(Validator::isPhone('+1234567890'));
     $this->assertFalse(Validator::isPhone('0800-LITHIUM'));
     Validator::add(array('phone' => array('foo' => '/^0800-[A-Z]+$/')));
     $this->assertTrue(Validator::isPhone('0800-LITHIUM'));
     $this->assertTrue(Validator::isPhone('0800-LITHIUM', 'foo'));
     $this->assertTrue(Validator::isPhone('0800-LITHIUM', 'any'));
 }
 public function testFrCa()
 {
     Validator::add(Catalog::read('validation', 'fr_CA'));
     $this->assertTrue(Validator::isPhone('(401) 321-9876'));
     $this->assertTrue(Validator::isPostalCode('M5J 2G8'));
     $this->assertTrue(Validator::isPostalCode('H2X 3X5'));
 }