app/models/active_fields/field/date.rb in active_fields-0.2.0 vs app/models/active_fields/field/date.rb in active_fields-1.0.0

- old
+ new

@@ -1,14 +1,20 @@ # frozen_string_literal: true module ActiveFields module Field class Date < ActiveFields.config.field_base_class - store_accessor :options, :required, :min, :max + acts_as_active_field( + validator: { + class_name: "ActiveFields::Validators::DateValidator", + options: -> { { required: required?, min: min, max: max } }, + }, + caster: { + class_name: "ActiveFields::Casters::DateCaster", + }, + ) - # attribute :required, :boolean, default: false - # attribute :min, :date - # attribute :max, :date + store_accessor :options, :required, :min, :max validates :required, exclusion: [nil] validates :max, comparison: { greater_than_or_equal_to: :min }, allow_nil: true, if: :min %i[required].each do |column|