Class: Rgltf::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/rgltf/validator.rb

Defined Under Namespace

Classes: Issue, Result

Constant Summary collapse

RULES =
[
  Validation::RootAssetExtensions,
  Validation::Buffers,
  Validation::Accessors,
  Validation::ImagesMaterials,
  Validation::Meshes,
  Validation::ScenesNodes,
  Validation::Skins,
  Validation::Animations,
  Validation::Cameras
].freeze

Class Method Summary collapse

Class Method Details

.validate(value) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/rgltf/validator.rb', line 36

def validate(value)
  document = value if value.respond_to?(:raw_json)
  json = document ? document.raw_json : value
  context = Validation::Context.new(json, document:)
  RULES.each { |rule| run_rule(rule, context) }
  Result.new(errors: context.errors.freeze, warnings: context.warnings.freeze)
end