You are here

function fapi_validation_rule_ipv4 in Form API Validation 7

Same name and namespace in other branches
  1. 6 fapi_validation.module \fapi_validation_rule_ipv4()
  2. 7.2 fapi_validation.module \fapi_validation_rule_ipv4()
1 string reference to 'fapi_validation_rule_ipv4'
fapi_validation_fapi_validation_rules in ./fapi_validation.module
Implementation of hook_fapi_validation_rules

File

./fapi_validation.module, line 262

Code

function fapi_validation_rule_ipv4($value) {
  $pattern = '/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' . '(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/';
  return (bool) preg_match($pattern, $value);
}