Module: Reform::Validation::ClassMethods
- Defined in:
- lib/reform/validation.rb
Instance Method Summary collapse
- #deprecate_validation_positional_args(name, options) ⇒ Object
-
#validation(name = nil, options = {}, &block) ⇒ Object
DSL.
- #validation_group_class ⇒ Object
- #validation_groups ⇒ Object
Instance Method Details
#deprecate_validation_positional_args(name, options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/reform/validation.rb', line 20 def deprecate_validation_positional_args(name, ) if name.is_a?(Symbol) warn "[Reform] Form::validation API is now: validation(name: :default, if:nil, schema:Schema). Please use keyword arguments instead of positional arguments." return {name: name}.merge() end return {name: :default}.merge() if name.nil? {name: :default}.merge(name) end |
#validation(name = nil, options = {}, &block) ⇒ Object
DSL.
10 11 12 13 14 15 16 17 18 |
# File 'lib/reform/validation.rb', line 10 def validation(name = nil, = {}, &block) = deprecate_validation_positional_args(name, ) name = [:name] # TODO: remove in favor of kw args in 3.0. heritage.record(:validation, , &block) group = validation_groups.add(name, ) group.instance_exec(&block) end |
#validation_group_class ⇒ Object
31 32 33 34 |
# File 'lib/reform/validation.rb', line 31 def validation_group_class raise NoValidationLibraryError, "no validation library loaded. Please include a " + "validation library such as Reform::Form::Dry" end |