Class: NxtErrorRegistry::DefaultCodeValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/nxt_error_registry/default_code_validator.rb

Constant Summary collapse

CodeAlreadyTakenError =
Class.new(StandardError)
InvalidCodeFormatError =
Class.new(StandardError)
LEGACY_FORMAT =
/\A\d{3}\.\d{3}\z/
FORMAT =
/\A[a-zA-Z0-9-]{36}|#{LEGACY_FORMAT}\z/

Instance Method Summary collapse

Constructor Details

#initialize(name, type, code, context) ⇒ DefaultCodeValidator

Returns a new instance of DefaultCodeValidator.



9
10
11
12
13
14
# File 'lib/nxt_error_registry/default_code_validator.rb', line 9

def initialize(name, type, code, context)
  @name = name
  @type = type
  @code = code
  @context = context
end

Instance Method Details

#validateObject



16
17
18
19
20
21
# File 'lib/nxt_error_registry/default_code_validator.rb', line 16

def validate
  validate_code_format
  validate_code_uniqueness

  code
end