Module: EnvValidator::Types

Defined in:
lib/env_validator/types.rb

Defined Under Namespace

Classes: Base, Base64, Boolean, DirPath, Email, FilePath, Float, Integer, Json, String, URL

Constant Summary collapse

TYPE_REGISTRY =

Registry for type lookup

{
  string: String,
  integer: Integer,
  float: Float,
  boolean: Boolean,
  url: URL,
  email: Email,
  json: Json,
  base64: Base64,
  file_path: FilePath,
  dir_path: DirPath
}.freeze

Class Method Summary collapse

Class Method Details

.get_validator(type) ⇒ Object

Raises:

  • (ArgumentError)


169
170
171
172
173
174
# File 'lib/env_validator/types.rb', line 169

def self.get_validator(type)
  validator_class = TYPE_REGISTRY[type.to_sym]
  raise ArgumentError, "Unknown type: #{type}" unless validator_class

  validator_class.new
end