Class: DearInventory::Validators::Guid
- Inherits:
-
DearInventory::Validator
- Object
- DearInventory::Validator
- DearInventory::Validators::Guid
- Extended by:
- T::Sig
- Defined in:
- lib/dear_inventory/validators/guid.rb
Constant Summary collapse
- REGEX =
T.let( [ /\A[\da-f]{32}\z/i, /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i, ].freeze, T::Array[Regexp] )
Instance Method Summary collapse
Methods inherited from DearInventory::Validator
Constructor Details
This class inherits a constructor from DearInventory::Validator
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/dear_inventory/validators/guid.rb', line 18 def call value = instance_variable_get(:@value) return if value.nil? return if REGEX.any? { |regex| value =~ regex } raise_error("#{value.inspect} is not a valid GUID") end |