Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation: use default language if not provided #213

Closed
System-Glitch opened this issue Jun 26, 2024 · 1 comment
Closed

Validation: use default language if not provided #213

System-Glitch opened this issue Jun 26, 2024 · 1 comment
Assignees
Labels
enhancement Enhancement of existing feature

Comments

@System-Glitch
Copy link
Member

Proposal

When using validation manually, not providing the Language field in the validation.Options will trigger a panic: runtime error: invalid memory address or nil pointer dereference.

We should load the built-in default language (en-US) if the option is omitted. Or we could use an empty language that would return only the name of the entry.

Possible drawbacks

Loading the default language for every validation can reduce performance a bit. This would still be very much recommended to use the option. This would need to be properly documented.

@System-Glitch System-Glitch added the enhancement Enhancement of existing feature label Jun 26, 2024
@BowlOfSoup
Copy link
Contributor

As you suggested in the discusion on Discord, we could also detect if a language is been given. If not, we just return the entry name/input-as-is without translation, thus not using a language lookup in validator.go:processAddedErrors().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants