Commit 6d81cfe
feat: add 17 built-in validators for common use cases (#36)
* docs: Add CLAUDE.md with project guidelines
- Complete project structure overview
- Common commands and workflows
- Release process (always use ./scripts/release.sh)
- Architecture details and optimizations
- Linting, testing, and CI/CD guides
- Troubleshooting tips
This file provides context for Claude Code to work more effectively
with the project without repeating instructions.
* Add CHANGELOG.md for release tracking
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: add 17 built-in validators for common use cases
Implements Pydantic-like validators using msgspec.Meta and custom str subclasses:
**Numeric validators (8):**
- PositiveInt, NegativeInt, NonNegativeInt, NonPositiveInt
- PositiveFloat, NegativeFloat, NonNegativeFloat, NonPositiveFloat
**String validators (9):**
- EmailStr (RFC 5321 validation)
- HttpUrl (HTTP/HTTPS only), AnyUrl (any scheme)
- SecretStr (masks sensitive data in repr/str)
- PostgresDsn, RedisDsn (connection string validation)
- PaymentCardNumber (Luhn algorithm validation + masking)
- FilePath, DirectoryPath (filesystem validation)
**Implementation:**
- Numeric types use msgspec.Meta for native C validation
- String types use custom __new__ validation with proper error messages
- dec_hook in settings.py for automatic type conversion
- Enhanced _preprocess_env_value to handle Annotated types
- 71 comprehensive tests (152 total)
**Documentation:**
- Complete README section with examples and validator table
- New example file (06_validators.py) demonstrating all 17 validators
- Updated Features section to highlight validators
All tests passing ✅ (152/152)
Lint clean ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: resolve Ruff lint and CodeQL security warnings
**Ruff fixes:**
- Auto-format all files (3 files reformatted)
- Move tempfile import to top of file
- Remove unused variables in try/except blocks
- Add noqa directive for PLR0915 (too many statements in example main)
- Fix import ordering in test_types.py
**CodeQL fixes:**
- Add nosec comments for fake credentials in examples
- Mark example passwords/secrets as test data
All 152 tests passing ✅
Lint clean ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: add CodeQL suppression annotations for example fake credentials
* fix: configure CodeQL to exclude examples from security scanning
Created CodeQL config to exclude examples/ folder from analysis.
Example files contain fake credentials for demonstration purposes only.
References:
- https://github.com/github/codeql/blob/main/.github/codeql/codeql-config.yml
- https://stackoverflow.com/questions/74030852/is-there-a-way-to-exclude-files-from-codeql-scanning-on-github
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3964e50 commit 6d81cfe
File tree
8 files changed
+1760
-4
lines changed- .github
- codeql
- workflows
- examples
- src/msgspec_ext
- tests
8 files changed
+1760
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
102 | 197 | | |
103 | 198 | | |
104 | 199 | | |
| |||
0 commit comments