Module: Moon::DataModel::Validators

Defined in:
lib/data_model/validators.rb,
lib/data_model/validators/type.rb,
lib/data_model/validators/base.rb

Overview

Various Validators usable by Field

Defined Under Namespace

Classes: Base, Type

Class Method Summary collapse

Class Method Details

.entriesHash

Returns the validators registry


39
40
41
# File 'lib/data_model/validators.rb', line 39

def self.entries
  @registry
end

.fetch(key) ⇒ Validator::Base

Fecthes a validator by key


30
31
32
33
34
# File 'lib/data_model/validators.rb', line 30

def self.fetch(key)
  @registry.fetch(key) do
    raise NoSuchValidator, "could not a find a validator for key: #{key}"
  end
end

.register(key, validator) ⇒ Object

Registers a Validator


14
15
16
# File 'lib/data_model/validators.rb', line 14

def self.register(key, validator)
  @registry[key] = validator
end

.registered?(key) ⇒ Boolean

Returns whether or not there is a registered validator for the key.


22
23
24
# File 'lib/data_model/validators.rb', line 22

def self.registered?(key)
  @registry.key?(key)
end