ISqlValidator class abstract

CHECK constraint validation check (SQL generation).

IMPORTANT for implementors: The sql property MUST be declared as a final String sql field (not a computed getter) so that the code generator can read it via Dart's constant evaluation at build time.

✅ Correct — final field, readable at generation time:

class MyValidator implements ISqlValidator {
  @override
  final String sql;
  const MyValidator() : sql = '{column} IS NOT NULL';
}

✅ Also correct for parameterized validators (ternary is a const expression):

class RangeValidator implements ISqlValidator {
  @override
  final String sql;
  const RangeValidator(int min, int max)
    : sql = '{column} BETWEEN $min AND $max';
}

❌ Wrong — computed getter cannot be read by the generator:

@override
String get sql { // will NOT generate a CHECK constraint
  if (someCondition) return '...';
  return '...';
}

For validators whose SQL depends on a list of values and cannot be expressed as a const expression (e.g., IN (...) clauses), the generator will automatically fall back to reading the values field and constructing the IN clause.

Implemented types

Constructors

ISqlValidator()
Const base constructor.
const

Properties

constraint String?
Optional constraint name (CONSTRAINT name for CHECK constraint or error name for JSON validation).
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sql String
The SQL template expression. Can contain {column} as a placeholder.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited