validate method
void
validate()
Implementation
void validate() {
if (modelVersion < _minModelVersion) {
throw StateError(
'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 StateError(
'the loaded model has been created with a newer generator version $modelVersion, while the maximum supported version is $_maxModelVersion. Please upgrade your toolchain/generator');
}
var lastEntityIdFound = false;
for (final e in entities) {
if (e.model != this) {
throw StateError(
"entity '${e.name}' with id ${e.id} has incorrect parent model reference");
}
e.validate();
if (lastEntityId.id < e.id.id) {
throw StateError(
"lastEntityId $lastEntityId is lower than the one of entity '${e.name}' with id ${e.id}");
}
if (lastEntityId.id == e.id.id) {
if (lastEntityId.uid != e.id.uid) {
throw StateError(
"lastEntityId $lastEntityId does not match entity '${e.name}' with id ${e.id}");
}
lastEntityIdFound = true;
}
}
if (!lastEntityIdFound && !retiredEntityUids.contains(lastEntityId.uid)) {
throw StateError('lastEntityId $lastEntityId does not match any entity');
}
if (!lastRelationId.isEmpty || hasRelations()) {
var lastRelationIdFound = false;
for (final e in entities) {
for (final r in e.relations) {
if (lastRelationId.id < r.id.id) {
throw StateError(
"lastRelationId $lastRelationId is lower than the one of relation '${r.name}' with id ${r.id}");
}
if (lastRelationId.id == r.id.id) {
if (lastRelationId.uid != r.id.uid) {
throw StateError(
"lastRelationId $lastRelationId does not match relation '${r.name}' with id ${r.id}");
}
lastRelationIdFound = true;
}
}
}
if (!lastRelationIdFound &&
!retiredRelationUids.contains(lastRelationId.uid)) {
throw StateError(
'lastRelationId $lastRelationId does not match any standalone relation');
}
}
}