Sha256: dc72518c326fa844e8e6a4ac33d26a7ba27d21aae5c91018b0c747ddbf9953ce
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 Bytes
Contents
module ActiveModel class Serializer module Validator module Mixin extend ActiveSupport::Concern # Validate the rendered data against a JSON schema file def valid_against_schema?(schema) JSON::Validator.validate(schema, self.to_json) end # Return whether the serializer output is valid def valid? valid_against_schema?(self.class.json_schema) end module ClassMethods # Set the JSON schema to use for this class 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 end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_model_serializers_validator-0.1.1 | lib/active_model/serializer/validator/mixin.rb |