Module: Kharon::Helpers

Defined in:
lib/validate.rb

Instance Method Summary collapse

Instance Method Details

#validate(datas, &block) ⇒ Hash

Validates the datas passed as parameter with a Phenix::Validator and the given instructions.

Parameters:

  • datas (Hash)

    the parameters to validate with the given instructions.

  • block (Proc)

    the instructions to apply on the validator.

Returns:

  • (Hash)

    the validated and filtered datas.



8
9
10
11
12
# File 'lib/validate.rb', line 8

def validate(datas, &block)
  validator = Kharon::Factory.validator(datas)
  validator.instance_eval(&block)
  return validator.filtered
end