Sha256: be576230b84997105805781185e71e65105b673a2d2e110e9c3afbf09ee2c522
Contents?: true
Size: 1.05 KB
Versions: 6
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module RustyJSONSchema # Handles release of the pointer automatically # with Ruby GC. This way we can intialize validator # in Rust, and hold a reference in Ruby. # class Validator < FFI::AutoPointer # Custom GC flow for our validator, freeing # the object within Rust # def self.release(pointer) Binding.free(pointer) end # Simple validation without actual error messages # # ## Examples # # validator = RustyJSONSchema.build(json_schema) # validator.valid?(event) # # => false|true # def valid?(event) Binding.is_valid(self, RustyJSONSchema.dump(event)) end # Full validation and error messages # # ## Examples # # validator = RustyJSONSchema.build(json_schema) # validator.validate(event) # # => [ # # 'path "/foo": "rusty" is not a "number"', # # ... # # ] # def validate(event) Binding.validate(self, RustyJSONSchema.dump(event)).to_a end end end
Version data entries
6 entries across 6 versions & 4 rubygems