Class: ActionController::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/ca/validation/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#errors(full: false) ⇒ Object



9
10
11
# File 'lib/ca/validation/core_ext.rb', line 9

def errors(full: false)
  @result.messages(full: full)
end

#resultObject



13
14
15
# File 'lib/ca/validation/core_ext.rb', line 13

def result
  @result.to_hash
end

#valid?(validator) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'lib/ca/validation/core_ext.rb', line 3

def valid?(validator)
  dup_params = deep_dup
  @result = validator.call(dup_params.permit!.to_hash)
  @result.errors.empty?
end