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

Documentation is unclear to available validator methods #1529

Open
392781 opened this issue Feb 23, 2024 · 2 comments
Open

Documentation is unclear to available validator methods #1529

392781 opened this issue Feb 23, 2024 · 2 comments
Labels
documentation Issue that requires updating docs enhancement good first issue Easy things for newbies

Comments

@392781
Copy link

392781 commented Feb 23, 2024

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).

@392781 392781 added bug triage Trying to make sure if this is valid or not labels Feb 23, 2024
@sisp
Copy link
Member

sisp commented Feb 23, 2024

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.

@yajo
Copy link
Member

yajo commented Mar 9, 2024

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.

@yajo yajo added this to the Community contribution milestone Mar 9, 2024
@sisp sisp added documentation Issue that requires updating docs enhancement good first issue Easy things for newbies and removed bug triage Trying to make sure if this is valid or not labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issue that requires updating docs enhancement good first issue Easy things for newbies
Projects
None yet
Development

No branches or pull requests

3 participants