Module: Ohm::WebValidations
- Included in:
- ExtraValidations
- Defined in:
- lib/ohm/contrib/web_validations.rb
Overview
All credit goes to gnrfan of github Basically an extraction from github.com/gnrfan/ohm_extra_validations
-
2010-05-29 Updated Email Regex, Extracted out regexs to constants
This module provides the following:
-
assert_slug
-
assert_email
-
assert_url
-
assert_ipv4
Constant Summary collapse
- EMAIL_REGEX =
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i
- SLUG_REGEX =
/^[-\w]+$/
- URL_REGEX =
/^(http|https):\/\/([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}|(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}|localhost)(:[0-9]{1,5})?(\/.*)?$/ix
- IPV4_REGEX =
/^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/