Module: Kharon::Validate
- Defined in:
- lib/kharon/validate.rb
Overview
Module to include to use the #validate method in your own classes. It offers an easier way to validate datas than creating the validator from scratch.
Instance Method Summary (collapse)
-
- (Hash) validate(datas, &block)
Validates the datas passed as parameter with a Kharon::Validator and the given instructions.
Instance Method Details
- (Hash) validate(datas, &block)
Validates the datas passed as parameter with a Kharon::Validator and the given instructions.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kharon/validate.rb', line 9 def validate(datas, &block) begin validator = Kharon::Validator.new(datas) validator.instance_eval(&block) return validator.filtered rescue Kharon::Errors::Validation => exception raise exception rescue Exception => exception raise Kharon::Errors::Validation.new({type: "standard", exception: exception.class.to_s, message: exception., backtrace: exception.backtrace}) end end |