Module: Sequel::Plugins::AutoValidations::InstanceMethods
- Defined in:
- lib/sequel/plugins/auto_validations.rb
Instance Method Summary collapse
-
#validate ⇒ Object
Validate the model’s auto validations columns.
Instance Method Details
#validate ⇒ Object
Validate the model’s auto validations columns
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/sequel/plugins/auto_validations.rb', line 162 def validate super opts = model. unless (not_null_columns = model.auto_validate_not_null_columns).empty? if model.auto_validate_presence? validates_presence(not_null_columns, opts[:not_null]) else validates_not_null(not_null_columns, opts[:not_null]) end end unless (not_null_columns = model.auto_validate_explicit_not_null_columns).empty? if model.auto_validate_presence? validates_presence(not_null_columns, opts[:explicit_not_null]) else validates_not_null(not_null_columns, opts[:explicit_not_null]) end end unless (max_length_columns = model.auto_validate_max_length_columns).empty? max_length_columns.each do |col, len| validates_max_length(len, col, opts[:max_length]) end end validates_schema_types(keys, opts[:schema_types]) if model.auto_validate_types? unique_opts = Hash[opts[:unique]] if model.respond_to?(:sti_dataset) unique_opts[:dataset] = model.sti_dataset end model.auto_validate_unique_columns.each{|cols| validates_unique(cols, unique_opts)} end |