validateIntegrity method
- Insertable<
MyUserRow> instance, { - 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<MyUserRow> 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('num')) {
context.handle(
_numMeta, num.isAcceptableOrUnknown(data['num']!, _numMeta));
} else if (isInserting) {
context.missing(_numMeta);
}
if (data.containsKey('login')) {
context.handle(
_loginMeta, login.isAcceptableOrUnknown(data['login']!, _loginMeta));
}
if (data.containsKey('name')) {
context.handle(
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
}
if (data.containsKey('bio')) {
context.handle(
_bioMeta, bio.isAcceptableOrUnknown(data['bio']!, _bioMeta));
}
if (data.containsKey('has_password')) {
context.handle(
_hasPasswordMeta,
hasPassword.isAcceptableOrUnknown(
data['has_password']!, _hasPasswordMeta));
}
if (data.containsKey('emails')) {
context.handle(_emailsMeta,
emails.isAcceptableOrUnknown(data['emails']!, _emailsMeta));
} else if (isInserting) {
context.missing(_emailsMeta);
}
if (data.containsKey('phones')) {
context.handle(_phonesMeta,
phones.isAcceptableOrUnknown(data['phones']!, _phonesMeta));
} else if (isInserting) {
context.missing(_phonesMeta);
}
if (data.containsKey('chat_direct_link')) {
context.handle(
_chatDirectLinkMeta,
chatDirectLink.isAcceptableOrUnknown(
data['chat_direct_link']!, _chatDirectLinkMeta));
}
if (data.containsKey('unread_chats_count')) {
context.handle(
_unreadChatsCountMeta,
unreadChatsCount.isAcceptableOrUnknown(
data['unread_chats_count']!, _unreadChatsCountMeta));
}
if (data.containsKey('status')) {
context.handle(_statusMeta,
status.isAcceptableOrUnknown(data['status']!, _statusMeta));
}
if (data.containsKey('avatar')) {
context.handle(_avatarMeta,
avatar.isAcceptableOrUnknown(data['avatar']!, _avatarMeta));
}
if (data.containsKey('call_cover')) {
context.handle(_callCoverMeta,
callCover.isAcceptableOrUnknown(data['call_cover']!, _callCoverMeta));
}
if (data.containsKey('presence_index')) {
context.handle(
_presenceIndexMeta,
presenceIndex.isAcceptableOrUnknown(
data['presence_index']!, _presenceIndexMeta));
}
if (data.containsKey('online')) {
context.handle(_onlineMeta,
online.isAcceptableOrUnknown(data['online']!, _onlineMeta));
}
if (data.containsKey('muted')) {
context.handle(
_mutedMeta, muted.isAcceptableOrUnknown(data['muted']!, _mutedMeta));
}
if (data.containsKey('blocklist_count')) {
context.handle(
_blocklistCountMeta,
blocklistCount.isAcceptableOrUnknown(
data['blocklist_count']!, _blocklistCountMeta));
}
context.handle(_lastSeenAtMeta, const VerificationResult.success());
if (data.containsKey('ver')) {
context.handle(
_verMeta, ver.isAcceptableOrUnknown(data['ver']!, _verMeta));
} else if (isInserting) {
context.missing(_verMeta);
}
if (data.containsKey('welcome_message')) {
context.handle(
_welcomeMessageMeta,
welcomeMessage.isAcceptableOrUnknown(
data['welcome_message']!, _welcomeMessageMeta));
}
return context;
}