Module: TableSchema::Constraints::MinLength

Included in:
TableSchema::Constraints
Defined in:
lib/tableschema/constraints/min_length.rb

Instance Method Summary collapse

Instance Method Details

#check_min_lengthObject



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

def check_min_length
  return if @value.nil?
  if @value.length < parsed_min_length
    raise TableSchema::ConstraintError.new("The field `#{@field[:name]}` must have a minimum length of #{@constraints[:minLength]}")
  end
  true
end

#parsed_min_lengthObject



13
14
15
# File 'lib/tableschema/constraints/min_length.rb', line 13

def parsed_min_length
  @constraints[:minLength].to_i
end