Method: Iry::Macros#check_constraint
- Defined in:
- lib/iry/macros.rb
#check_constraint(key, name: nil, message: :invalid) ⇒ void
This method returns an undefined value.
Tracks check constraint for the given key and convert constraint errors into validation errors
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/iry/macros.rb', line 14 def check_constraint( key, name: nil, message: :invalid ) name ||= Constraint::Check.infer_name(key, table_name) if constraints.key?(name) raise ArgumentError, "Constraint already exists" end self.constraints = constraints.dup constraints[name] = Constraint::Check.new( key, message: , name: name ) end |