Sha256: 63b68dba3393174e01169d868b48ad09cb94ba5161c1c71df26c2278f4a6ddb9

Contents?: true

Size: 452 Bytes

Versions: 1

Compression:

Stored size: 452 Bytes

Contents

# frozen_string_literal: true

require 'json_schemer'

class Hws::Resources::Models::Resource < ActiveRecord::Base # :nodoc:
  attr_readonly :schema

  validate :validate_schema, on: :create

  private

  def validate_schema
    if self.schema.blank?
      errors.add(:schema, 'blank schema  specified')
      return
    end
    JSONSchemer.schema(self.schema)
  rescue StandardError => _e
    errors.add(:schema, 'invalid schema specified')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hws-resources-0.1.0 lib/hws-resources/models/resource.rb