fix(Champs::BooleanChamp): validates Champs::BooleanChamp respecting it's validation context.
This commit is contained in:
parent
d7f152f4af
commit
94ea16c894
1 changed files with 4 additions and 1 deletions
|
@ -5,7 +5,10 @@ class Champs::BooleanChamp < Champ
|
||||||
before_validation :set_value_to_nil, if: -> { value.blank? }
|
before_validation :set_value_to_nil, if: -> { value.blank? }
|
||||||
before_validation :set_value_to_false, unless: -> { ([nil, TRUE_VALUE, FALSE_VALUE]).include?(value) }
|
before_validation :set_value_to_false, unless: -> { ([nil, TRUE_VALUE, FALSE_VALUE]).include?(value) }
|
||||||
|
|
||||||
validates :value, inclusion: [TRUE_VALUE, FALSE_VALUE], allow_nil: true, allow_blank: false
|
validates :value, inclusion: [TRUE_VALUE, FALSE_VALUE],
|
||||||
|
allow_nil: true,
|
||||||
|
allow_blank: false,
|
||||||
|
if: :validate_champ_value?
|
||||||
|
|
||||||
def true?
|
def true?
|
||||||
value == TRUE_VALUE
|
value == TRUE_VALUE
|
||||||
|
|
Loading…
Reference in a new issue