Module: Kharon::Helpers

Defined in:
lib/kharon/helpers.rb,
lib/kharon/helpers/validate.rb

Overview

This module contains helpers made for Rails or Sinatra applications and using the Kharon validator.

Author:

Instance Method Summary (collapse)

Instance Method Details

- (Hash) validate(datas, &block)

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/kharon/helpers/validate.rb', line 8

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