Pear phone number validation

Hi - I’m new to Pear and need help to validate that a 10-digit phone number is entered. The complete phone number is entered in 3 text boxes (phone1 is 3 digits, phone2 is 3 digits, phone3 is 4 digits). If the phone number is blank or numbers are not entered, an error message appears. Now I need to make sure 10-digits are entered. Will “min_length”=> “3” work? Here’s my code:

case ‘phone’:
if( !is_numeric($paraValue[0]) || !is_numeric($paraValue[1]) || !is_numeric($paraValue[2]) )
$this->setError($paraString);

else {
$this->user[$paraString] = (int)$paraValue[0] . “-” . (int)$paraValue[1] . “-” . (int)$paraValue[2];
$this->user[‘phone1’] = $paraValue[0];
$this->user[‘phone2’] = $paraValue[1];
$this->user[‘phone3’] = $paraValue[2];
}

break;

If anyone is interested, I figured it out. Here’s the code I used after the else statement. It worked! You could probably combine these into one if statement using “and/or”.

if(!Validate::string($this->user[‘phone1’], array(‘min_length’=> ‘3’))) {
$this->setError($paraString);

} elseif(!Validate::string($this->user[‘phone2’], array(‘min_length’=> ‘3’))) {
$this->setError($paraString);

} elseif(!Validate::string($this->user[‘phone3’], array(‘min_length’=> ‘4’))) {
$this->setError($paraString);
}

Thanks :slight_smile: