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

Add YAMLParser.Feature.PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS to allow parsing "boolean" words as strings instead of booleans #388

Closed
axelniklasson opened this issue Feb 23, 2023 · 4 comments · Fixed by #389
Labels
2.15 Fix or feature targeted at 2.15 release yaml Issue related to YAML format backend
Milestone

Comments

@axelniklasson
Copy link
Contributor

Right now YAMLParser._matchYAMLBoolean provides no flexibility to avoid words that are considered booleans to be parsed as strings instead, which is actually sometimes the desired behaviour and a good candidate for a feature flag in my opinion. I therefore propose the following

  • Introduce a new YAMLParser.Feature called PARSE_TRUTHY_WORDS_AS_STRINGS (open for suggestion on names)
  • When enabling this flag, the following words (converted to lowercase) will be parsed as strings instead of booleans:
    • yes
    • no
    • on
    • off
    • y
    • n

Note that false and true will still be parsed as booleans.

Let me know what you think! I'll be happy to help out with a PR here.

Related issue: #129

@cowtowncoder
Copy link
Member

@axelniklasson Sounds reasonable, I would accept PR and help it get merged. Should go in 2.15 branch (new feature), could make it in 2.15.0 as we'll hope to start release-candidate phase soon.

@cowtowncoder cowtowncoder added yaml Issue related to YAML format backend 2.15 Fix or feature targeted at 2.15 release labels Feb 24, 2023
@axelniklasson
Copy link
Contributor Author

@cowtowncoder great, thanks for the quick response! I'll get started on the PR today.

@axelniklasson
Copy link
Contributor Author

@cowtowncoder PR ready here #389, let me know your thoughts!

@cowtowncoder
Copy link
Member

Looks pretty good, will add notes over there. Thanks!

@cowtowncoder cowtowncoder changed the title Add feature flag to allow parsing "boolean" words as strings instead of booleans Add YAMLParser.Feature.PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS to allow parsing "boolean" words as strings instead of booleans Feb 27, 2023
@cowtowncoder cowtowncoder added this to the 2.15.0 milestone Feb 27, 2023
cowtowncoder added a commit that referenced this issue Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.15 Fix or feature targeted at 2.15 release yaml Issue related to YAML format backend
Projects
None yet
2 participants