go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.07k stars 1.29k forks source link

Validation for python variable names #1195

Open jpodivin opened 8 months ago

jpodivin commented 8 months ago

This validation checks if string is a proper name for a python variable.

Fixes Or Enhances

Sometimes we may use our code to call external binaries, or even to construct what are effectively scripts. Python is relatively loose, but it does enforce rules about variable names rather vehemently. Specifically they must be generated by a specific grammar, and they must not be keywords[0].

The same restriction applies to ansible variables. So this validation may also be useful when one is constructing data structures intended to be used by ansible.

Make sure that you've checked the boxes below before you submit PR:

@go-playground/validator-maintainers

[0] https://docs.python.org/3/reference/lexical_analysis.html#identifiers

coveralls commented 8 months ago

Coverage Status

coverage: 73.918% (+0.02%) from 73.903% when pulling ade0b7f2dee1164f1f25fd328d36a30414c3a3ec on jpodivin:python into 84254aeb5a59e615ec0b66ab53b988bc0677f55e on go-playground:master.