Example #1
0
        $users->where('username = ?', $username);
        $user = $users->getFirst();
        if ($user->exists()) {
            echo "That name is already taken.\n";
        } else {
            $valid = true;
        }
    }
}
$valid = false;
while (!$valid) {
    echo "Email:";
    $email = trim(fgets(STDIN));
    if ($email) {
        $field = new Form_Field_Email();
        if ($field->validate($email, 'email')) {
            $users = new Model_User();
            $users->where('email = ?', $email);
            $user = $users->getFirst();
            if ($user->exists()) {
                echo "That address is already in use.\n";
            } else {
                $valid = true;
            }
        } else {
            echo $field->error() . "\n";
        }
    }
}
$valid = false;
while (!$valid) {
Example #2
0
File: unit.php Project: ssrsfs/blg
 public function testEmailValidation()
 {
     /** Assertions:
      * Check responses to a list of valid and invalid email addresses
      */
     $field = new Form_Field_Email();
     // Valid emails
     $field->validate('*****@*****.**', 'Email');
     $this->assertFalse($field->error(), "{$field->input()} should not have returned an error");
     $field->validate('*****@*****.**', 'Email');
     $this->assertFalse($field->error(), "{$field->input()} should not have returned an error");
     $field->validate('*****@*****.**', 'Email');
     // Invalid emails
     $this->assertFalse($field->error(), "{$field->input()} should not have returned an error");
     $field->validate('nodomain', 'Email');
     $this->assertTrue($field->error(), "{$field->input()} should have returned an error");
     $field->validate('invalidseparator+domain.com', 'Email');
     $this->assertTrue($field->error(), "{$field->input()} should have returned an error");
 }