Merge pull request #1 from willemwollebrants/improved-email-validator

Improved email validator
This commit is contained in:
Jabari Hunt 2018-01-31 10:30:06 -06:00 committed by GitHub
commit 11dc3a7850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -121,6 +121,7 @@ V::lang('ar');
* `notIn` - Negation of `in` rule (not in array of values) * `notIn` - Negation of `in` rule (not in array of values)
* `ip` - Valid IP address * `ip` - Valid IP address
* `email` - Valid email address * `email` - Valid email address
* `emailDNS` - Valid email address with active DNS record
* `url` - Valid URL * `url` - Valid URL
* `urlActive` - Valid URL with active DNS record * `urlActive` - Valid URL with active DNS record
* `alpha` - Alphabetic characters only * `alpha` - Alphabetic characters only

View File

@ -560,6 +560,18 @@ class ValidateTest extends BaseTestCase
$this->assertFalse($v->validate()); $this->assertFalse($v->validate());
} }
public function testEmailDnsValid(){
$v = new Validator(array('name' => 'Chester Tester', 'email' => 'chester@tester.com'));
$v->rule('emailDNS', 'email');
$this->assertTrue($v->validate());
}
public function testEmailDnsInvalid(){
$v = new Validator(array('name' => 'Chester Tester', 'email' => 'chester@tester.zyx'));
$v->rule('emailDNS', 'email');
$this->assertFalse($v->validate());
}
public function testUrlValid() public function testUrlValid()
{ {
$v = new Validator(array('website' => 'http://google.com')); $v = new Validator(array('website' => 'http://google.com'));