本文整理匯總了PHP中lithium\util\Validator::isPhone方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::isPhone方法的具體用法?PHP Validator::isPhone怎麽用?PHP Validator::isPhone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lithium\util\Validator
的用法示例。
在下文中一共展示了Validator::isPhone方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testMultipleLocales
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);
}
示例2: testAddCustomRegexFormats
/**
* 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'));
}
示例3: testFrCa
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'));
}