mardi 19 septembre 2017

Conflict when use validates_format_of for two fields

I very new to the world of Ruby on Rails, but my problem is: when I just type the following code:

validates_format_of :ipaddress, :with => Resolv::IPv4::Regex

It works exactly as I want. But when I do:

validates_format_of :ipaddress, :with => Resolv::IPv4::Regex
validates_format_of :domain, :with => /\A[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}\z/

The tests start to point failures at the IP validation. Why this is happening?

Aucun commentaire:

Enregistrer un commentaire