Module: JsClientBridge::Responses::Validation
- Included in:
- JsClientBridge::Responses
- Defined in:
- lib/js-client-bridge/responses/validation.rb
Instance Method Summary collapse
-
#render_validation(*args) ⇒ String
Generates a validation error status response.
-
#respond_with_validation_error(*args) ⇒ Hash
Generates a validation error status response.
Instance Method Details
#render_validation(*args) ⇒ String
Generates a validation error status response. If the first parameter is a string is will be used as the _status options. It will also honour custom optionss as long they don’t clash with the standard ones.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/js-client-bridge/responses/validation.rb', line 42 def render_validation(*args) obj = args.shift = args.last.is_a?(Hash) ? args.pop : {} # Generate our response hash and add the exceptions parameter response = if .include?(:message) .merge( validation_errors_to_hash(obj, .delete(:message)) ) else .merge( validation_errors_to_hash(obj) ) end format_response(response, ) end |
#respond_with_validation_error(*args) ⇒ Hash
Generates a validation error status response. If the first parameter is a string is will be used as the _status options. It will also honour custom optionss as long they don’t clash with the standard ones.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/js-client-bridge/responses/validation.rb', line 17 def respond_with_validation_error(*args) obj = args.shift = args.last.is_a?(Hash) ? args.pop : {} # Generate our response hash and add the exceptions parameter response = if .include?(:message) .merge( validation_errors_to_hash(obj, .delete(:message)) ) else .merge( validation_errors_to_hash(obj) ) end response end |