validateIntegrity method
- Insertable<
ChatRow> 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<ChatRow> 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('avatar')) {
context.handle(_avatarMeta,
avatar.isAcceptableOrUnknown(data['avatar']!, _avatarMeta));
}
if (data.containsKey('name')) {
context.handle(
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
}
if (data.containsKey('members')) {
context.handle(_membersMeta,
members.isAcceptableOrUnknown(data['members']!, _membersMeta));
}
if (data.containsKey('kind_index')) {
context.handle(_kindIndexMeta,
kindIndex.isAcceptableOrUnknown(data['kind_index']!, _kindIndexMeta));
}
if (data.containsKey('is_hidden')) {
context.handle(_isHiddenMeta,
isHidden.isAcceptableOrUnknown(data['is_hidden']!, _isHiddenMeta));
}
if (data.containsKey('muted')) {
context.handle(
_mutedMeta, muted.isAcceptableOrUnknown(data['muted']!, _mutedMeta));
}
if (data.containsKey('direct_link')) {
context.handle(
_directLinkMeta,
directLink.isAcceptableOrUnknown(
data['direct_link']!, _directLinkMeta));
}
context.handle(_createdAtMeta, const VerificationResult.success());
context.handle(_updatedAtMeta, const VerificationResult.success());
if (data.containsKey('last_reads')) {
context.handle(_lastReadsMeta,
lastReads.isAcceptableOrUnknown(data['last_reads']!, _lastReadsMeta));
}
context.handle(_lastDeliveryMeta, const VerificationResult.success());
if (data.containsKey('first_item')) {
context.handle(_firstItemMeta,
firstItem.isAcceptableOrUnknown(data['first_item']!, _firstItemMeta));
}
if (data.containsKey('last_item')) {
context.handle(_lastItemMeta,
lastItem.isAcceptableOrUnknown(data['last_item']!, _lastItemMeta));
}
if (data.containsKey('last_read_item')) {
context.handle(
_lastReadItemMeta,
lastReadItem.isAcceptableOrUnknown(
data['last_read_item']!, _lastReadItemMeta));
}
if (data.containsKey('unread_count')) {
context.handle(
_unreadCountMeta,
unreadCount.isAcceptableOrUnknown(
data['unread_count']!, _unreadCountMeta));
}
if (data.containsKey('total_count')) {
context.handle(
_totalCountMeta,
totalCount.isAcceptableOrUnknown(
data['total_count']!, _totalCountMeta));
}
if (data.containsKey('ongoing_call')) {
context.handle(
_ongoingCallMeta,
ongoingCall.isAcceptableOrUnknown(
data['ongoing_call']!, _ongoingCallMeta));
}
if (data.containsKey('favorite_position')) {
context.handle(
_favoritePositionMeta,
favoritePosition.isAcceptableOrUnknown(
data['favorite_position']!, _favoritePositionMeta));
}
if (data.containsKey('members_count')) {
context.handle(
_membersCountMeta,
membersCount.isAcceptableOrUnknown(
data['members_count']!, _membersCountMeta));
}
if (data.containsKey('ver')) {
context.handle(
_verMeta, ver.isAcceptableOrUnknown(data['ver']!, _verMeta));
} else if (isInserting) {
context.missing(_verMeta);
}
if (data.containsKey('last_item_cursor')) {
context.handle(
_lastItemCursorMeta,
lastItemCursor.isAcceptableOrUnknown(
data['last_item_cursor']!, _lastItemCursorMeta));
}
if (data.containsKey('last_read_item_cursor')) {
context.handle(
_lastReadItemCursorMeta,
lastReadItemCursor.isAcceptableOrUnknown(
data['last_read_item_cursor']!, _lastReadItemCursorMeta));
}
if (data.containsKey('recent_cursor')) {
context.handle(
_recentCursorMeta,
recentCursor.isAcceptableOrUnknown(
data['recent_cursor']!, _recentCursorMeta));
}
if (data.containsKey('favorite_cursor')) {
context.handle(
_favoriteCursorMeta,
favoriteCursor.isAcceptableOrUnknown(
data['favorite_cursor']!, _favoriteCursorMeta));
}
return context;
}