Module: JsClientBridge::Responses::Validation
- Included in:
- JsClientBridge::Responses
- Defined in:
- lib/js-client-bridge/responses/validation.rb
Instance Method Summary collapse
-
#respond_with_validation_error(*args) ⇒ Object
Generates a validation error status response.
Instance Method Details
#respond_with_validation_error(*args) ⇒ Object
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.
Parameters
- message<String>
-
An optional message.
- options<Hash>
-
Custom optionss.
Returns
- JSON String
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/js-client-bridge/responses/validation.rb', line 16 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 format_response(response, ) end |