Class: Reform::Contract
- Inherits:
-
Disposable::Twin
- Object
- Disposable::Twin
- Reform::Contract
- Includes:
- Disposable::Twin::Sync, Expose, Readonly, Validate, Validation
- Defined in:
- lib/reform/contract.rb,
lib/reform/result.rb,
lib/reform/contract/validate.rb,
lib/reform/contract/custom_error.rb
Overview
Define your form structure and its validations. Instantiate it with a model, and then validate
this object graph.
Direct Known Subclasses
Defined Under Namespace
Modules: Readonly, Validate Classes: CustomError, Result
Constant Summary
Constants included from Validation
Validation::NoValidationLibraryError
Class Method Summary collapse
- .default_nested_class ⇒ Object
- .properties(*args) ⇒ Object
- .property(name, options = {}, &block) ⇒ Object
Methods included from Readonly
Methods included from Validation
Methods included from Validate
#custom_errors, #errors, #initialize, #to_result, #validate, #validate!
Class Method Details
.default_nested_class ⇒ Object
13 14 15 |
# File 'lib/reform/contract.rb', line 13 def self.default_nested_class Contract end |
.properties(*args) ⇒ Object
29 30 31 32 |
# File 'lib/reform/contract.rb', line 29 def self.properties(*args) = args.last.is_a?(Hash) ? args.pop : {} args.each { |name| property(name, .dup) } end |
.property(name, options = {}, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/reform/contract.rb', line 17 def self.property(name, = {}, &block) if twin = .delete(:form) [:twin] = twin end if = [:validates] validates name, end super end |