validate method
Implementation
void validate() {
if (modelVersion < _minModelVersion) {
throw Exception(
'the loaded model is too old: version $modelVersion while the minimum supported is $_minModelVersion, consider upgrading with an older generator or manually');
}
if (modelVersion > _maxModelVersion) {
throw Exception(
'the loaded model has been created with a newer generator version $modelVersion, while the maximimum supported version is $_maxModelVersion. Please upgrade your toolchain/generator');
}
if (entities == null) throw Exception('entities is null');
if (retiredEntityUids == null) throw Exception('retiredEntityUids is null');
if (retiredIndexUids == null) throw Exception('retiredIndexUids is null');
if (retiredPropertyUids == null) {
throw Exception('retiredPropertyUids is null');
}
if (retiredRelationUids == null) {
throw Exception('retiredRelationUids is null');
}
if (lastEntityId == null) throw Exception('lastEntityId is null');
var lastEntityIdFound = false;
for (final e in entities) {
if (e.model != this) {
throw Exception(
"entity '${e.name}' with id ${e.id.toString()} has incorrect parent model reference");
}
e.validate();
if (lastEntityId.id < e.id.id) {
throw Exception(
"lastEntityId ${lastEntityId.toString()} is lower than the one of entity '${e.name}' with id ${e.id.toString()}");
}
if (lastEntityId.id == e.id.id) {
if (lastEntityId.uid != e.id.uid) {
throw Exception(
"lastEntityId ${lastEntityId.toString()} does not match entity '${e.name}' with id ${e.id.toString()}");
}
lastEntityIdFound = true;
}
}
if (!lastEntityIdFound &&
!listContains(retiredEntityUids, lastEntityId.uid)) {
throw Exception(
'lastEntityId ${lastEntityId.toString()} does not match any entity');
}
}