Class: NxtSchema::Validators::Validator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register_as(*keys) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/nxt_schema/validators/validator.rb', line 4

def self.register_as(*keys)
  keys.each do |key|
    NxtSchema::Validators::REGISTRY.register(key, self)
  end

  define_method('key') { @key ||= keys.first }
end

Instance Method Details

#translate_error(locale, **options) ⇒ Object



12
13
14
# File 'lib/nxt_schema/validators/validator.rb', line 12

def translate_error(locale, **options)
  NxtSchema::Validators::ErrorMessages.resolve(locale, key, **options)
end