validateIntegrity method

  1. @override
VerificationContext validateIntegrity(
  1. Insertable<SessionRow> 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<SessionRow> instance,
    {bool isInserting = false}) {
  final context = VerificationContext();
  final data = instance.toColumns(true);
  if (data.containsKey('id')) {
    context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
  } else if (isInserting) {
    context.missing(_idMeta);
  }
  if (data.containsKey('ip')) {
    context.handle(_ipMeta, ip.isAcceptableOrUnknown(data['ip']!, _ipMeta));
  } else if (isInserting) {
    context.missing(_ipMeta);
  }
  if (data.containsKey('user_agent')) {
    context.handle(_userAgentMeta,
        userAgent.isAcceptableOrUnknown(data['user_agent']!, _userAgentMeta));
  } else if (isInserting) {
    context.missing(_userAgentMeta);
  }
  context.handle(_lastActivatedAtMeta, const VerificationResult.success());
  return context;
}