Module: Bosh::Director::ValidationHelper
- Included in:
- DeploymentPlan::AvailabilityZone, DeploymentPlan::CloudManifestParser, DeploymentPlan::CompilationConfig, DeploymentPlan::DeploymentSpecParser, DeploymentPlan::DiskType::DiskTypesParser, DeploymentPlan::DynamicNetwork, DeploymentPlan::Env, DeploymentPlan::GlobalNetworkResolver, DeploymentPlan::InstanceGroupSpecParser, DeploymentPlan::JobAvailabilityZoneParser, DeploymentPlan::JobNetworksParser, DeploymentPlan::ManualNetwork, DeploymentPlan::ManualNetworkSubnet, DeploymentPlan::Network, DeploymentPlan::Planner, DeploymentPlan::ReleaseVersion, DeploymentPlan::ResourcePool, DeploymentPlan::RuntimeManifestParser, DeploymentPlan::Stemcell, DeploymentPlan::Template, DeploymentPlan::UpdateConfig, DeploymentPlan::VmExtension, DeploymentPlan::VmType, Jobs::UpdateStemcell
- Defined in:
- lib/bosh/director/validation_helper.rb
Instance Method Summary collapse
Instance Method Details
#safe_property(hash, property, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bosh/director/validation_helper.rb', line 3 def safe_property(hash, property, = {}) if .has_key?(:default) && ![:default].nil? validate_property(property, , [:default], DefaultPropertyValidationMessage.new) end if !hash.nil? && !hash.kind_of?(Hash) raise Bosh::Director::ValidationInvalidType, "Object (#{hash.inspect}) did not match the required type 'Hash'" elsif !hash.nil? && hash.has_key?(property) return validate_property(property, , hash[property], PropertyValidationMessage.new) elsif .has_key?(:default) return [:default] elsif ![:optional] raise ValidationMissingField, "Required property '#{property}' was not specified in object (#{hash.inspect})" end end |