Sha256: 60dd03702e012b8150917ef624c27d9994d6294113892c3b7dc57a50c0116266

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'smart_core'
require 'smart_core/types'
require 'set'

# @api pulic
# @since 0.1.0
module SmartCore
  # @api public
  # @since 0.1.0
  class Schema
    require_relative 'schema/version'
    require_relative 'schema/errors'
    require_relative 'schema/key_control'
    require_relative 'schema/result'
    require_relative 'schema/checker'
    require_relative 'schema/dsl'

    # @since 0.1.0
    include SmartCore::Schema::DSL

    # @param verifiable_hash [Hash<String|Symbol,Any>]
    # @return [Boolean]
    #
    # @api public
    # @since 0.1.0
    def valid?(verifiable_hash)
      validate(verifiable_hash).success?
    end

    # @param verifiable_hash [Hash<String|Symbol,Any>]
    # @return [SmartCore::Schema::Result]
    #
    # @api public
    # @since 0.1.0
    def validate(verifiable_hash)
      schema_checker.check!(verifiable_hash)
    end

    private

    # @return [SmartCore::Schema::Checker]
    #
    # @api private
    # @since 0.1.0
    def schema_checker
      self.class.__schema_checker__
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
smart_schema-0.5.0 lib/smart_core/schema.rb
smart_schema-0.4.0 lib/smart_core/schema.rb
smart_schema-0.3.0 lib/smart_core/schema.rb
smart_schema-0.2.0 lib/smart_core/schema.rb
smart_schema-0.1.0 lib/smart_core/schema.rb