class Axlsx::RestrictionValidator
Validate a value against a specific list of allowed values.
Public Class Methods
validate(name, choices, v)
click to toggle source
Perform validation @param [String] name The name of what is being validatied. This is included in the error message @param [Array] choices The list of choices to validate against @param [Any] v The value to be validated @raise [ArgumentError] Raised if the value provided is not in the list of choices. @return [Boolean] true if validation succeeds.
# File lib/axlsx/util/validators.rb, line 11 def self.validate(name, choices, v) raise ArgumentError, (ERR_RESTRICTION % [v.to_s, name, choices.inspect]) unless choices.include?(v) true end