Module: ActiveModel::Serializer::Validator::Mixin::ClassMethods
- Defined in:
- lib/active_model/serializer/validator/mixin.rb
Instance Method Summary collapse
-
#json_schema(value = nil) ⇒ Object
Set the JSON schema to use for this class.
-
#valid_against_schema?(schema, serializer) ⇒ Boolean
Validate the rendered data against a JSON schema file and return an errors array.
Instance Method Details
#json_schema(value = nil) ⇒ Object
Set the JSON schema to use for this class
19 20 21 22 23 24 25 26 |
# File 'lib/active_model/serializer/validator/mixin.rb', line 19 def json_schema(value = nil) @_json_schema ||= begin superclass.json_schema if superclass.respond_to?(:json_schema) end return @_json_schema unless value @_json_schema = value end |
#valid_against_schema?(schema, serializer) ⇒ Boolean
Validate the rendered data against a JSON schema file and return an errors array
30 31 32 |
# File 'lib/active_model/serializer/validator/mixin.rb', line 30 def valid_against_schema?(schema, serializer) JSON::Validator.fully_validate(schema, serializer.to_json) end |