NLeSC / python-template

Netherlands eScience Center Python Template
https://research-software-directory.org/software/nlesc-python-template
Apache License 2.0
186 stars 76 forks source link

Add validator for double and single quotes in name and description #407

Closed lyashevska closed 2 months ago

lyashevska commented 3 months ago

This can be used for inspiration

full_name:
  type: str
  default: Jane Smith
  help: Enter your full name.
  # validator: >-
  #       {% if '"' in full_name %}
  #       full_name must not contain unescaped double quotes. Use \\" for double quotes.
  #       {% endif %}
abelsiqueira commented 2 months ago

We're using a regex to validate the package name: https://github.com/abelsiqueira/BestieTemplate.jl/blob/b1114d039578dbd5a132a8955c87352e6371448d/copier.yml#L9 Maybe it's helpful, maybe it's overkill.

lyashevska commented 2 months ago

@abelsiqueira thanks, this is great indeed. We also use it for some of the variables. I thinks the original functionality was to ensure that any double/single quotes are escaped. Do we want to allow this? I guess it is debatable. This was implemented via cookicutter hooks like so: "full_name": cookiecutter.full_name.replace('\"', '\\\"'),

lyashevska commented 2 months ago

Closing as addressed via #414