Module: PDK::Config::Validator
- Defined in:
- lib/pdk/config/validator.rb
Overview
A collection of predefined validators for use with Value.
Class Method Summary collapse
-
.boolean ⇒ Hash{Symbol => [Proc,String]}
A Value validator that ensures that the value is either a TrueClass or FalseClass.
-
.uuid ⇒ Hash{Symbol => [Proc,String]}
A Value validator that ensures that the value is a String that matches the regex for a version 4 UUID.
Class Method Details
.boolean ⇒ Hash{Symbol => [Proc,String]}
Returns a PDK::Config::Value validator that ensures that the value is either a TrueClass or FalseClass.
13 14 15 16 17 18 |
# File 'lib/pdk/config/validator.rb', line 13 def self.boolean { proc: ->(value) { [true, false].include?(value) }, message: 'must be a boolean: true or false' } end |
.uuid ⇒ Hash{Symbol => [Proc,String]}
Returns a PDK::Config::Value validator that ensures that the value is a String that matches the regex for a version 4 UUID.
23 24 25 26 27 28 |
# File 'lib/pdk/config/validator.rb', line 23 def self.uuid { proc: ->(value) { value.match(/\A\h{8}(?:-\h{4}){3}-\h{12}\z/) }, message: 'must be a version 4 UUID' } end |