lithium\tests\cases\util\ValidatorTest::testAddCustomRegexFormats PHP Method

testAddCustomRegexFormats() public method

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'));
    }