I don’t think that default Rails validators will do the trick here, you can do this though:
validate :validate_wdays
def validate_wdays
if !wdays.is_a?(Array) || wdays.any?{|d| !(0..6).include?(d)}
errors.add(:wdays, :invalid)
end
end
I don’t think that default Rails validators will do the trick here, you can do this though:
validate :validate_wdays
def validate_wdays
if !wdays.is_a?(Array) || wdays.any?{|d| !(0..6).include?(d)}
errors.add(:wdays, :invalid)
end
end