Class: Schematic::Generator::Restrictions::Length

Inherits:
Base show all
Defined in:
lib/schematic/generator/restrictions/length.rb

Instance Attribute Summary

Attributes inherited from ColumnValidator

#column, #klass

Instance Method Summary collapse

Methods inherited from ColumnValidator

#for_validator, #initialize, #validators_for_column

Constructor Details

This class inherits a constructor from Schematic::Generator::ColumnValidator

Instance Method Details

#generate(builder) ⇒ Object



7
8
9
10
11
12
# File 'lib/schematic/generator/restrictions/length.rb', line 7

def generate(builder)
  for_validator ActiveModel::Validations::LengthValidator do |validator|
    builder.xs(:maxLength, 'value' => validator.options[:maximum]) if validator.options[:maximum]
    builder.xs(:minLength, 'value' => validator.options[:minimum]) if validator.options[:minimum]
  end
end