Documentation is unclear to available validator methods
392781 opened this issue · comments
Describe the problem
In this documentation example, a function(?) called regex_search
is used:
validator: >-
{% if not (project_name | regex_search('^[a-z][a-z0-9\-]+$')) %}
project_name must start with a letter, followed one or more letters, digits or dashes all lowercase.
{% endif %}
There is no further mention of this in the documentation or any additional validator methods that are discussed. It is also not part of the jinja2 docs.
Template
NA
To Reproduce
No response
Logs
No response
Expected behavior
Please include available validation commands in the documentation.
Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
NA
Copier version
9.1.1
Python version
NA
Installation method
pipx+pypi
Additional context
I am trying to find if it is possible to validate input based on existing file names or bash command outputs (for instance trying to validate that a response to a question is unique based on grep
output in bash... regex seems to exist with regex_search
but no further validation methods are documented).
All built-in Jinja2 functions/filters/tests, filters from jinja2-ansible-filters
(which includes regex_search
), and the function pathjoin
are available. Additional Jinja2 extensions can be registered via the _jinja_extensions
setting in copier.yml
. regex_search
is no validation method but simply a Jinja2 filter. Using grep
output isn't supported out of the box, it may be added via a custom Jinja2 extension, but I'm not sure it's a good idea because grep
may not be available on all systems and – depending on what exactly you're planning to do – validation may become non-deterministic.
Thanks for your feedback! Would you like to open a PR to improve the docs?
I don't want to replicate docs from jinja2-ansible-filters, but a info box could help indeed.