Class: FormKeeper::Validator
- Inherits:
-
Object
- Object
- FormKeeper::Validator
- Defined in:
- lib/formkeeper.rb
Constant Summary collapse
- @@filter_store =
{}
- @@constraint_store =
{}
- @@combination_constraint_store =
{}
Class Method Summary collapse
- .register_combination_constraint(name, constraint) ⇒ Object
- .register_constraint(name, constraint) ⇒ Object
- .register_filter(name, filter) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Validator
constructor
A new instance of Validator.
- #validate(params, rule, messages = nil) ⇒ Object
Constructor Details
#initialize ⇒ Validator
Returns a new instance of Validator.
739 740 |
# File 'lib/formkeeper.rb', line 739 def initialize end |
Class Method Details
.register_combination_constraint(name, constraint) ⇒ Object
709 710 711 |
# File 'lib/formkeeper.rb', line 709 def self.register_combination_constraint(name, constraint) @@combination_constraint_store[name] = constraint end |
.register_constraint(name, constraint) ⇒ Object
705 706 707 |
# File 'lib/formkeeper.rb', line 705 def self.register_constraint(name, constraint) @@constraint_store[name] = constraint end |
.register_filter(name, filter) ⇒ Object
701 702 703 |
# File 'lib/formkeeper.rb', line 701 def self.register_filter(name, filter) @@filter_store[name] = filter end |
Instance Method Details
#validate(params, rule, messages = nil) ⇒ Object
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
# File 'lib/formkeeper.rb', line 742 def validate(params, rule, =nil) report = Report.new() rule.fields.each do |name, criteria| criteria.filters.concat(rule.default_filters) report << validate_field(name, criteria, params, rule.encoding_filter) end rule.checkboxes.each do |name, criteria| criteria.filters.concat(rule.default_filters) report << validate_checkbox(name, criteria, params, rule.encoding_filter) end rule.combinations.each do |name, criteria| criteria.filters.concat(rule.default_filters) report << validate_combination(name, criteria, params, rule.encoding_filter) end return report end |