validateIntegrity method

  1. @override
VerificationContext validateIntegrity(
  1. Insertable<BlocklistRow> instance, {
  2. bool isInserting = false,
})
override

Validates that the given entity can be inserted into this table, meaning that it respects all constraints (nullability, text length, etc.).

Implementation

@override
VerificationContext validateIntegrity(Insertable<BlocklistRow> instance,
    {bool isInserting = false}) {
  final context = VerificationContext();
  final data = instance.toColumns(true);
  if (data.containsKey('user_id')) {
    context.handle(_userIdMeta,
        userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
  } else if (isInserting) {
    context.missing(_userIdMeta);
  }
  if (data.containsKey('reason')) {
    context.handle(_reasonMeta,
        reason.isAcceptableOrUnknown(data['reason']!, _reasonMeta));
  }
  context.handle(_atMeta, const VerificationResult.success());
  if (data.containsKey('cursor')) {
    context.handle(_cursorMeta,
        cursor.isAcceptableOrUnknown(data['cursor']!, _cursorMeta));
  }
  return context;
}