Sha256: 79c3831518eec7f4c97f0b013047037628eb3face48da3a060aa4699e4576361
Contents?: true
Size: 606 Bytes
Versions: 5
Compression:
Stored size: 606 Bytes
Contents
module Medivo class ArrayValidator < ActiveModel::Validator def validate(record) for field in options[:fields] value = record.attributes[field] record.errors.add(field, "#{field} must be an array") unless value.is_a? Array end end end class DateValidator < ActiveModel::Validator def validate(record) for field in options[:fields] value = record.attributes[field] date = Date.strptime(value, '%Y%m%d') rescue nil record.errors.add(field, "invalid #{field}. needs to be in '%Y%m%d' format") unless date end end end end
Version data entries
5 entries across 5 versions & 1 rubygems