validate ip

This commit is contained in:
Han Lin Yap 2012-01-26 18:26:54 +01:00
parent a36e2773e2
commit 5974a58b3f
1 changed files with 12 additions and 0 deletions

View File

@ -426,6 +426,18 @@ protected function validate_unique($attribute, $value, $parameters)
return $query->count() == 0; return $query->count() == 0;
} }
/**
* Validate that an attribute is a valid IP.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
protected function validate_ip($attribute, $value)
{
return filter_var($value, FILTER_VALIDATE_IP) !== false;
}
/** /**
* Validate that an attribute is a valid e-mail address. * Validate that an attribute is a valid e-mail address.