backend API to create a launcher

This commit is contained in:
zadam
2022-12-22 14:57:00 +01:00
parent 059c339c09
commit 8ec2547b4a
32 changed files with 947 additions and 173 deletions

View File

@@ -117,11 +117,15 @@ class Attribute extends AbstractEntity {
validate() {
if (!["label", "relation"].includes(this.type)) {
throw new Error(`Invalid attribute type '${this.type}' in attribute '${this.attributeId}'`);
throw new Error(`Invalid attribute type '${this.type}' in attribute '${this.attributeId}' of note '${this.noteId}'`);
}
if (!this.name?.trim()) {
throw new Error(`Invalid empty name in attribute '${this.attributeId}'`);
throw new Error(`Invalid empty name in attribute '${this.attributeId}' of note '${this.noteId}'`);
}
if (this.type === 'relation' && !(this.value in this.becca.notes)) {
throw new Error(`Cannot save relation '${this.name}' of note '${this.noteId}' since it target not existing note '${this.value}'.`);
}
}
@@ -204,11 +208,7 @@ class Attribute extends AbstractEntity {
beforeSaving() {
this.validate();
if (this.type === 'relation') {
if (!(this.value in this.becca.notes)) {
throw new Error(`Cannot save relation '${this.name}' since it target not existing note '${this.value}'.`);
}
} else if (!this.value) {
if (!this.value) {
// null value isn't allowed
this.value = "";
}