Module: JsonTableSchema::Constraints::MaxLength

Included in:
JsonTableSchema::Constraints
Defined in:
lib/jsontableschema/constraints/max_length.rb

Instance Method Summary collapse

Instance Method Details

#check_max_lengthObject



5
6
7
8
9
10
11
# File 'lib/jsontableschema/constraints/max_length.rb', line 5

def check_max_length
  return if @value.nil?
  if @value.length > @constraints['maxLength'].to_i
    raise JsonTableSchema::ConstraintError.new("The field `#{@field['name']}` must have a maximum length of #{@constraints['maxLength']}")
  end
  true
end