We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 51d2c2f commit 923a803Copy full SHA for 923a803
1 file changed
lib/jsonapi_errorable/validatable.rb
@@ -1,13 +1,17 @@
1
module JsonapiErrorable
2
module Validatable
3
- # @param relationships: nil [Hash] list of relationships to be serialized as errors
+ # @param relationships: nil [ Hash or FalseClass ] list of relationships whose errors should be serialized
4
+ # Defaults to the deserialized data.relationships of Json:api Payload
5
# @param record [ ActiveModel ] Object that implements ActiveModel
6
def render_errors_for(record, relationships: nil)
- validation = Serializers::Validation.new(
7
- record,
+
8
+ relationships = if relationships == false
9
+ {}
10
+ else
11
relationships || deserialized_params.relationships
- )
-
12
+ end
13
14
+ validation = Serializers::Validation.new(record, relationships)
15
16
render \
17
json: { errors: validation.errors },
0 commit comments