lib/medivo/validators.rb in medivo-0.0.8 vs lib/medivo/validators.rb in medivo-0.0.9
- old
+ new
@@ -6,9 +6,19 @@
record.errors.add(field, "#{field} must be an array") unless value.is_a? Array
end
end
end
+ class TestTypesValidator < ActiveModel::Validator
+ def validate(record)
+ for field in options[:fields]
+ value = record.attributes[field]
+ valid = value.is_a?(String) and value.split(",").is_a?(Array) rescue false
+ record.errors.add(field, "#{field} must be a comma delimited string of one of more test id's' like so: \"test_type1\" or \"test_type1, test_type2\" ") unless valid
+ end
+ end
+ end
+
# A valid date for the orders is a little different that usual .. so take note '%Y%m%d'
# has no slashes or dashes .. so a date is valid that looks like: '20111202'
class DateValidator < ActiveModel::Validator
def validate(record)
for field in options[:fields]
\ No newline at end of file