Skip to content

Conversation

@emirkmo
Copy link
Owner

@emirkmo emirkmo commented May 19, 2025

Introduce a CaseInsensitiveLiteral type to enhance Pydantic model validation by allowing case-insensitive string matching for defined literal values. Improve documentation and tests for the new functionality while ensuring existing integrations remain intact. Clean up test cases and resolve type variable errors.

emirkmo added 9 commits May 19, 2025 22:20
- Add direct tests for the inner validator function from case_insensitive_literal_validator, including type and value error cases.
- Assert that the returned validator is a PlainValidator instance.
- Ensure all case-insensitive variants are tested for canonical value mapping.
- Add/clarify docstrings and comments for test clarity.
- Retain and verify Pydantic model integration and error handling.
Only place we still use Literal is for tagged discriminators
in pydantic. This is because pydantic requires enum or literal
for the discriminator type. For these, we don't want case insensitive
behavior.
@emirkmo
Copy link
Owner Author

emirkmo commented May 19, 2025

Used copilot agent mode and github code environment to create this while watching some dota2.. Interesting that it worked okay.

@emirkmo emirkmo merged commit 196d678 into main May 19, 2025
5 checks passed
@emirkmo emirkmo deleted the case-insensitive-literal branch May 19, 2025 23:35
@emirkmo emirkmo linked an issue May 19, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Literal type checking should respect AnyCase from the json schema

2 participants