From 5974a58b3fc4c5dab346006f0235abc9dc8622b3 Mon Sep 17 00:00:00 2001 From: Han Lin Yap Date: Thu, 26 Jan 2012 18:26:54 +0100 Subject: [PATCH] validate ip --- laravel/validator.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/laravel/validator.php b/laravel/validator.php index f7912065..7d1a765a 100644 --- a/laravel/validator.php +++ b/laravel/validator.php @@ -426,6 +426,18 @@ protected function validate_unique($attribute, $value, $parameters) 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.