module MyJohnDeereApi::Validators::Asset
Constants
- VALID_CATEGORIES
Private Instance Methods
required_attributes()
click to toggle source
# File lib/my_john_deere_api/validators/asset.rb, line 18 def required_attributes [:organization_id, :title] end
valid_categories?(category, type, subtype)
click to toggle source
Returns boolean, true if this combination is valid
# File lib/my_john_deere_api/validators/asset.rb, line 31 def valid_categories?(category, type, subtype) VALID_CATEGORIES.dig(category, type).to_a.include?(subtype) end
validate_attributes()
click to toggle source
# File lib/my_john_deere_api/validators/asset.rb, line 22 def validate_attributes unless valid_categories?(attributes[:asset_category], attributes[:asset_type], attributes[:asset_sub_type]) errors[:asset_category] = 'requires valid combination of category/type/subtype' end end