Module: SkullIsland::Validations::Resource
- Included in:
- Resource
- Defined in:
- lib/skull_island/validations/resource.rb
Overview
Resource validation methods
Instance Method Summary collapse
-
#validate_id ⇒ Object
The ‘id’ field should not be set manually.
- #validate_mutability ⇒ Object
-
#validate_required_properties(data) ⇒ Object
Ensure that required properties are set before saving.
-
#validate_tags(value) ⇒ Object
Used to validate #tags on set.
Instance Method Details
#validate_id ⇒ Object
The ‘id’ field should not be set manually
12 13 14 |
# File 'lib/skull_island/validations/resource.rb', line 12 def validate_id raise Exceptions::NewInstanceWithID if @entity.key?('id') && @tainted end |
#validate_mutability ⇒ Object
7 8 9 |
# File 'lib/skull_island/validations/resource.rb', line 7 def validate_mutability raise Exceptions::ImmutableModification if immutable? && @tainted # this shouldn't happen end |
#validate_required_properties(data) ⇒ Object
Ensure that required properties are set before saving
17 18 19 20 21 |
# File 'lib/skull_island/validations/resource.rb', line 17 def validate_required_properties(data) required_properties.each do |name, _value| raise Exceptions::InvalidArguments if data[name.to_s].nil? end end |
#validate_tags(value) ⇒ Object
Used to validate #tags on set
24 25 26 27 28 29 30 |
# File 'lib/skull_island/validations/resource.rb', line 24 def (value) # allow only valid hostnames value.each do |tag| return false unless tag.is_a?(String) && tag.match?(/^[\w_\-\.~]+$/) end true end |