# DurationValidator## Validate the format conforms with ChronicDuration## Example:## class ApplicationSetting < ActiveRecord::Base# validates :default_artifacts_expire_in, presence: true, duration: true# end#classDurationValidator<ActiveModel::EachValidatordefvalidate_each(record,attribute,value)ChronicDuration.parse(value)rescueChronicDuration::DurationParseErrorrecord.errors.add(attribute,"is not a correct duration")endend