validateIntegrity method

  1. @override
VerificationContext validateIntegrity(
  1. Insertable<DraftRow> 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<DraftRow> instance,
    {bool isInserting = false}) {
  final context = VerificationContext();
  final data = instance.toColumns(true);
  if (data.containsKey('chat_id')) {
    context.handle(_chatIdMeta,
        chatId.isAcceptableOrUnknown(data['chat_id']!, _chatIdMeta));
  } else if (isInserting) {
    context.missing(_chatIdMeta);
  }
  if (data.containsKey('data')) {
    context.handle(
        _dataMeta, this.data.isAcceptableOrUnknown(data['data']!, _dataMeta));
  } else if (isInserting) {
    context.missing(_dataMeta);
  }
  return context;
}