Class: GcxSiteNameValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- GcxSiteNameValidator
- Defined in:
- lib/validators/gcx_site_name_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/validators/gcx_site_name_validator.rb', line 3 def validate_each(record, attribute, value) if value =~ /^[a-z][a-z0-9_\-]{2,79}$/i res = RestClient.get(GcxApi.gcx_url + "/wp-gcx/check-name.php?name=#{value}") doc = Ox.parse(res) unless doc.nodes.first.attributes[:result] == 'true' record.errors[attribute] << "is already taken" end end end |