class Mv::Sqlite::Validation::Builder::Format

Public Instance Methods

conditions() click to toggle source
# File lib/mv/sqlite/validation/builder/format.rb, line 8
def conditions
  [{
    statement: apply_allow_nil_and_blank(apply_with(column_reference)),
    message: message
  }]
end

Protected Instance Methods

apply_with(stmt) click to toggle source
# File lib/mv/sqlite/validation/builder/format.rb, line 27
def apply_with stmt
  "#{stmt} REGEXP #{db_value(with)}"
end
db_value(value) click to toggle source
# File lib/mv/sqlite/validation/builder/format.rb, line 17
def db_value value
  return "'#{value.source}'" if value.is_a?(Regexp)
  return "'#{value.to_s}'" if value.is_a?(String)
  raise Mv::Core::Error.new(table_name: table_name,
                            column_name: column_name,
                            validation_type: :inclusion,
                            options: { in: value },
                            error: "#{value.class} is not supported as :with value")
end