-
-
Save lbvf50mobile/a90665a0e927a1be009706fe6ca2bc7a to your computer and use it in GitHub Desktop.
Validations for IP address and MAC address on Ruby on Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "resolv" | |
class Model < ActiveRecord::Base | |
validates :ip_address, format: { with: Resolv::IPv4::Regex } | |
validates :mac_address, format: { with: /\A([0-9A-F]{2}[-:]){5}([0-9A-F]{2})\z/ } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment