Skip to content

Commit

Permalink
feat(byline): add validation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed May 23, 2024
1 parent 64874f2 commit 1352bca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions db/model/Gdoc/GdocBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,20 @@ export class GdocBase implements OwidGdocBaseInterface {
}

async validate(knex: db.KnexReadonlyTransaction): Promise<void> {
const authorErrors = this.content.authors.reduce(
(errors: OwidGdocErrorMessage[], name): OwidGdocErrorMessage[] => {
if (!this.linkedAuthors.find((a) => a.title === name)) {
errors.push({
property: "linkedAuthors",
message: `Author "${name}" does not exist or is not published`,
type: OwidGdocErrorMessageType.Warning,
})
}
return errors
},
[]
)

const filenameErrors: OwidGdocErrorMessage[] = this.filenames.reduce(
(
errors: OwidGdocErrorMessage[],
Expand Down Expand Up @@ -798,6 +812,7 @@ export class GdocBase implements OwidGdocBaseInterface {

const subclassErrors = await this._validateSubclass(knex, this)
this.errors = [
...authorErrors,
...filenameErrors,
...linkErrors,
...contentErrors,
Expand Down

0 comments on commit 1352bca

Please sign in to comment.