Conversation
- Add :enum alias for :in validation - Add flattened validators: min, max, greater_than, less_than - Add length validators: min_length, max_length, min_items, max_items - Add ignore_unknown option to skip unknown validators - Refactor validation system using pattern matching instead of get_validator - Unify number and decimal validation with backward compatibility - Mark validate_decimal as deprecated in favor of validate_number - Remove @supported_validations list and manual validator filtering - Add comprehensive tests and documentation examples 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Skip type validation when no type is explicitly specified
- Only validate type when type: key is provided in validators
- Improves performance for constraint-only validations
- Add tests and documentation for type-less validation behavior
Examples:
- Valdi.validate("hello", min_length: 3) # No type check, just length
- Valdi.validate(15, min: 10, max: 20) # No type check, just bounds
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Reviewer's GuideThis PR refactors the Valdi module to support flattened validation syntax, unify number and Decimal validations, simplify dispatch logic with direct pattern matching, introduce an ignore_unknown option, and update documentation and tests accordingly. Sequence diagram for validation with ignore_unknown optionsequenceDiagram
participant Caller
participant Valdi
Caller->>Valdi: validate(value, [type: :string, unknown: :foo], ignore_unknown: true)
Valdi->>Valdi: prepare_validator(validators)
Valdi->>Valdi: do_validate(value, validators, :ok, opts)
Valdi->>Valdi: do_validate(value, {:type, :string}, opts)
Valdi->>Valdi: do_validate(value, {:unknown, :foo}, opts)
Valdi-->>Caller: :ok
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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
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 by Sourcery
Flatten validation syntax by introducing top-level min/max, greater_than/less_than, length and items aliases, unify number and Decimal validation under validate_number/2, add ignore_unknown option, deprecate validate_decimal/2, refactor dispatch logic, and update docs and tests.
New Features:
Enhancements:
Tests: