Skip to content

Commit

Permalink
All validation in Address file wouldn't have worked, fixed so now it …
Browse files Browse the repository at this point in the history
…does
  • Loading branch information
dabates committed Sep 11, 2011
1 parent aa50305 commit ed8a745
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Ordrin/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ function validate($element = "all") {
// do ALL validation
if (!preg_match('/(^\d{5}$)|(^\d{5}-\d{4}$)/', $this->zip)) {
parent::$_errors[] = 'Address - validation - zip code (invalid) (' . $this->zip . ')';
} elseif (!preg_match('/(^\(?(\d{3})\)?[- .]?(\d{3})[- .]?(\d{4})$)/', $this->phone) && $this->phone != "") {
}

if (!preg_match('/(^\(?(\d{3})\)?[- .]?(\d{3})[- .]?(\d{4})$)/', $this->phone) && $this->phone != "") {
parent::$_errors[] = 'Address - validation - phone number (invalid) (' . $this->phone . ')';
} elseif (!preg_match('/[A-z.-]/', $this->city)) {
}

if (!preg_match('/[A-z.-]/', $this->city)) {
parent::$_errors[] = 'Address - validation - city (invalid, only letters/spaces allowed) (' . $this->city . ')';
} elseif (!preg_match('/^([A-z]){2}$/', $this->state) && $this->$state != "") {
}

if (!preg_match('/^([A-z]){2}$/', $this->state) && $this->$state != "") {
parent::$_errors[] = 'Address - validation - state (invalid, only letters allowed and must be passed as two-letter abbreviation) (' . $this->state . ')';
}
}
Expand Down

0 comments on commit ed8a745

Please sign in to comment.