Skip to content

Add validation logic#37

Merged
MrGreenTea merged 10 commits intomainfrom
han2-ro/feat/implement-validation-logic
Feb 14, 2025
Merged

Add validation logic#37
MrGreenTea merged 10 commits intomainfrom
han2-ro/feat/implement-validation-logic

Conversation

@Han2-Ro
Copy link
Copy Markdown
Contributor

@Han2-Ro Han2-Ro commented Jun 28, 2024

Add validation rules: If Eventpage is enabled, require Hero Image, Content tile, content, ....

@Han2-Ro Han2-Ro force-pushed the han2-ro/feat/implement-validation-logic branch from 7fd1b67 to cbdb21f Compare October 24, 2024 13:22
@Han2-Ro
Copy link
Copy Markdown
Contributor Author

Han2-Ro commented Oct 25, 2024

TODO:

  • make every field for event page required if slug exists
  • tests: extract validations into function for easier testing
  • add descriptions

Comment thread src/collections/Events.ts
Comment thread src/collections/Events.ts Outdated
Comment thread src/collections/Events.ts
Comment thread src/collections/Events.ts
},
validate(value: string, options) {
if (value && value.match(/^[a-z0-9][a-z0-9\-]+[a-z0-9]$/) == null) {
return "Es sind nur Kleinbuchstaben(a-z), Ziffern(0-9) und Bindestriche(-) erlaubt. Der slug muss mindestens 3 Zeichen lang sein. Bindestriche dürfen nich am Anfang oder Ende sein.";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "Es sind nur Kleinbuchstaben(a-z), Ziffern(0-9) und Bindestriche(-) erlaubt. Der slug muss mindestens 3 Zeichen lang sein. Bindestriche dürfen nich am Anfang oder Ende sein.";
return "Es sind nur Kleinbuchstaben(a-z), Ziffern(0-9) und Bindestriche(-) erlaubt. Der Slug muss mindestens 3 Zeichen lang sein. Bindestriche dürfen nicht am Anfang oder Ende sein.";

Comment thread src/collections/Events.ts
description: ({ value }: { value?: unknown }) =>
value
? `Eventseite erreichbar unter: https://youngvision.org/events/${value ?? ""} Entferne den slug um keine Eventseite zu generieren.`
: "Es wird keine Eventseite erstellt, weil der slug leer ist."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: "Es wird keine Eventseite erstellt, weil der slug leer ist."
: "Es wird keine Eventseite erstellt, weil der Slug leer ist."

Comment thread src/collections/Events.ts
admin: {
description: ({ value }: { value?: unknown }) =>
value
? `Eventseite erreichbar unter: https://youngvision.org/events/${value ?? ""} Entferne den slug um keine Eventseite zu generieren.`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
? `Eventseite erreichbar unter: https://youngvision.org/events/${value ?? ""} Entferne den slug um keine Eventseite zu generieren.`
? `Eventseite erreichbar unter: https://youngvision.org/events/${value ?? ""} Entferne den Slug um keine Eventseite zu generieren.`

@MrGreenTea MrGreenTea force-pushed the han2-ro/feat/implement-validation-logic branch from 5aeacff to 4aabdbb Compare February 14, 2025 09:55
@Han2-Ro Han2-Ro marked this pull request as ready for review February 14, 2025 10:14
@MrGreenTea MrGreenTea merged commit e9674e6 into main Feb 14, 2025
@MrGreenTea MrGreenTea deleted the han2-ro/feat/implement-validation-logic branch February 14, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants