I know the validation format for IPv4 and IPv6. But not sure how I can combine them so atleast one format should be true. Here is my validation
validates :src_ip_addr, :presence => true, :uniqueness => true,
:format => { :with => Resolv::IPv4::Regex, :message => "Not an valid IPv4 format"}
validates :src_ip_addr, :presence => true, :uniqueness => true,
:format => { :with => Resolv::IPv6::Regex, :message => "Not an valid IPv6 format"}
How I can combine them so if one format is correct then validation should work. Should fail only if ipv4 and ipv6 format is not correct.
Thanks.
However, due to the rich number of methods Rails gives you to interact with validations in general, you can build your own. In addition, when generating a scaffold, Rails will put some ERB into the _form.html.erb that it generates that displays the full list of errors on that model.
A default static route is a destination IP address 0.0.0.0/0. Ipv4 Config - ( ip route 0.0.0.0 0.0.0.0 <ip for next-hop OR exit interface on the router>) Ipv6 Config - ( ip route ::/0 <ip for next-hop OR exit interface on the router>)
– (ipv6 route <network-to-route-to>/ <subnet-mask> <exit interface on the router OR next-hop ip address>) A host route is used to route traffic to a specific host NOT Network. The subnet mask in the route will always be all 1’s which means non CIDR is 255.25.255.255 that is /32 for IPv4 and /128 for IPv6.
And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome on the rubyonrails-docs mailing list .
You can also combine them with Regexp.union
:
:format => { :with => Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With