Class: RSchema::Schemas::Anything

Inherits:
Object
  • Object
show all
Defined in:
lib/rschema/schemas/anything.rb

Overview

A schema that matches literally any value

Examples:

The anything schema

schema = RSchema.define { anything }
schema.valid?(nil) #=> true
schema.valid?(6.2) #=> true
schema.valid?({ hello: Time.now }) #=> true

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject


15
16
17
# File 'lib/rschema/schemas/anything.rb', line 15

def self.instance
  @instance ||= new
end

Instance Method Details

#call(value, options) ⇒ Object


19
20
21
# File 'lib/rschema/schemas/anything.rb', line 19

def call(value, options)
  Result.success(value)
end

#with_wrapped_subschemas(wrapper) ⇒ Object


23
24
25
# File 'lib/rschema/schemas/anything.rb', line 23

def with_wrapped_subschemas(wrapper)
  self
end