chore: improve template error message (#22324)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
Michael Pollmeier 2025-07-13 12:38:12 +02:00 • committed by GitHub
parent 62a14a6756
commit f943c9c3e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,8 +63,9 @@ func (t *Template) Validate() error {
}
maxLength := 50
if len(p.Description.String("en")) > maxLength || len(p.Description.String("de")) > maxLength {
return fmt.Errorf("description for param %s is too long in template %s. use help field for details: %s", p.Name, t.Template, p.Description.String("en"))
actualLength := max(len(p.Description.String("en")), len(p.Description.String("de")))
if actualLength > maxLength {
return fmt.Errorf("description for param %s is too long in template %s. allowed: %d. actual length: %d. use help field for details instead.", p.Name, t.Template, maxLength, actualLength)
}
switch p.Name {