class Thumbtack::Types::LengthValidation

Handles validation of the length of values

@api private

Public Class Methods

validate(value, maximum_length) click to toggle source

Validate a value

@param [Object] maximum_length

the maximum length

@param [Object] value

the value to validate

@return [self]

@raise [Types::ValidationError]

if the value is not less or equal to the maximum length
# File lib/thumbtack/types/length_validation.rb, line 20
def self.validate(value, maximum_length)
  unless value.length <= maximum_length
    raise ValidationError,
          "#{value} cannot be greater than #{maximum_length} characters"
  end
  self
end