-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add advanced validators - IP, MAC, dates, storage, and more #39
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
Merged
github-actions
merged 20 commits into
msgflux:main
from
vilsonrodrigues:feat/add-validators-phase2
Dec 3, 2025
Merged
feat: add advanced validators - IP, MAC, dates, storage, and more #39
github-actions
merged 20 commits into
msgflux:main
from
vilsonrodrigues:feat/add-validators-phase2
Dec 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements 9 new powerful validators: **Network & Data Types:** - IPv4Address, IPv6Address, IPvAnyAddress - IP address validation - Json - JSON string validation - MacAddress - MAC address with multiple format support **String Constraints:** - ConStr - Constrained strings with min/max length and regex patterns **Storage & Dates:** - ByteSize - Parse byte sizes with units (KB, MB, GB, KiB, MiB, etc) - PastDate, FutureDate - Date validation for past/future dates **Bonus Exports:** - Added msgspec.Raw and msgspec.UNSET re-exports for convenience **Test Coverage:** - Added 67 comprehensive tests (all passing) - Total: 127 type validator tests All validators integrate seamlessly with BaseSettings via dec_hook. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Removed Json validator type as it adds unnecessary complexity: - JSON strings are better validated when used, not when loaded - Using plain `str` type is clearer and more flexible - Simplifies _preprocess_env_value logic - Reduces dec_hook complexity Updated: - Removed _Json class from types.py - Removed Json from all imports and exports - Removed Json tests (121 tests passing) - Updated example to remove JSON validation section - Renamed example to 08_advanced_validators.py All 121 type tests passing ✓ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Created test_integration.py with 18 integration tests ensuring all validators work correctly with BaseSettings: **Test Coverage:** - Numeric types: PositiveInt, NegativeInt, PositiveFloat - String validators: EmailStr, HttpUrl, SecretStr - Database DSNs: PostgresDsn, RedisDsn - Path validators: FilePath, DirectoryPath - Network validators: IPv4Address, IPv6Address, IPvAnyAddress, MacAddress - Storage & Dates: ByteSize, PastDate, FutureDate - Complete integration: All validators working together **Test Results:** - 18 integration tests: ✓ ALL PASSING - 121 unit tests: ✓ ALL PASSING - Total: 220 tests passing in 0.31s Integration tests verify environment variable parsing, type conversion, and validation work correctly end-to-end with BaseSettings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…port Major improvements to README.md: **New Description:** - Updated from "settings management" to "settings management and validation library" - Better reflects the dual nature of the project **Enhanced Type Support Section:** - **All msgspec native types** - Emphasized full compatibility with msgspec's rich type system - Added link to msgspec supported types: https://jcristharif.com/msgspec/supported-types.html - Listed key native types: datetime, UUID, Decimal, collections, etc. - Highlighted msgspec.Raw and msgspec.UNSET re-exports **26 Custom Validators - Organized by Category:** - 🔢 Numeric Constraints (8 types) - 🌐 Network & Hardware (4 types) - NEW: IP addresses, MAC addresses - ✉️ String Validators (4 types) - 🗄️ Database & Connections (3 types) - 📁 Path Validators (2 types) - 💾 Storage & Dates (3 types) - NEW: ByteSize, PastDate, FutureDate - 🎯 Constrained Strings (2 types) - NEW: ConStr **New Advanced Usage Examples:** - Storage size parsing with ByteSize - Date validation (past/future) - Complete examples for all new validators **Updated Comparison Table:** - Added "Validators" row: msgspec-ext (26) vs pydantic-settings (~15) - Emphasized validator advantage **Better Structure:** - Quick Start shows validators immediately - Type Support section right after installation - Clear categorization with emojis for easy scanning - Complete validator table with all 26 types Result: README now clearly communicates that msgspec-ext is both a settings management tool AND a comprehensive validation library with 26 specialized validators + all msgspec native types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced project metadata to reflect evolution: **Updated Description:** - Old: "Fast settings management using msgspec" - New: "High-performance settings management and validation library extending msgspec" - Cleaner, emphasizes extension of msgspec **Added Keywords (11 total):** - msgspec, settings, configuration - validation, validators - pydantic (for discoverability) - environment-variables, dotenv - type-validation - fast, performance **Enhanced Classifiers:** - Added "Intended Audience :: System Administrators" - Added "Topic :: System :: Systems Administration" - Added "Typing :: Typed" (for type-safe libraries) These changes improve: - 🔍 PyPI search discoverability - 📊 Better project categorization - 🎯 Clear communication of dual purpose (settings + validation) - 🏷️ Relevant keywords for users searching for pydantic alternatives 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2ec729e to
62627cd
Compare
- Renamed examples/08_advanced_validators.py to 07_advanced_validators.py - Updated README references to use correct example number - Fixed integration test structure and removed redundant tests - All 220 tests passing
- Export dec_hook and enc_hook for use with msgspec structs - Add 'With msgspec Structs' section to Quick Start - Add msgspec struct examples to validator sections (Network, Storage) - Add 'Use Cases' section with real-world examples: - API Request/Response validation - Configuration files with validation - Message queue data validation (MessagePack) - Add enc_hook for serializing custom types to JSON/MessagePack - Update pyproject.toml to ignore UP038 lint rule - All validators now work seamlessly with both BaseSettings and msgspec.Struct
- Add practical output examples in Quick Start section - Show model_dump() and model_dump_json() outputs for BaseSettings - Add print outputs in API Request/Response example - Add outputs in Configuration Files example - Enhance Nested Configuration with full dump example - Add Secret Masking serialization examples - Add ByteSize serialization output - Helps users understand what to expect when serializing settings
Fix CI formatting check failure
Contributor
Author
|
/merge |
|
✅ PR merged successfully by @vilsonrodrigues! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds 8 powerful advanced validators to msgspec-ext:
Network & Hardware
ipaddressmoduleString Constraints
min_length,max_length, and regexpatternsupportStorage & Dates
date.today()Bonus Features
Test Coverage
Examples
New example file
examples/08_advanced_validators.pydemonstrates:Implementation Details
BaseSettingsvia_dec_hookstr)Breaking Changes
None - all new features, fully backward compatible.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com