-
Notifications
You must be signed in to change notification settings - Fork 0
refactor validation system, add unit tests and documentation #1
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
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
- Added attribute-based validation using the `Validate` attribute - Implemented EmailValidator and RangeValidator for common validation tasks - Integrated ContentValidator for pipeline-based entity validation - Added exception handling with ValidationException and PSR-3 logging support
- Added `Validate` attribute for validation configuration. - Created `ValidationException` for handling validation-related exceptions. - Introduced `AbstractValidatorProcessor` as a base class for all validators. - Added date processors: `DateFormatValidator` and `DateRangeValidator`. - Added input processors: `EmailValidator`, `LengthValidator`, and `UrlValidator`. - Added logic processors: `ConditionalValidator` and `RequiredValidator`. - Added numeric processors: `IntegerValidator` and `RangeValidator`. - Implemented main `Validator` class to manage validations. - Updated `composer.json` and `composer.lock` for dependencies. - Modified `tests/application.php` to include new validation tests.
- Add new validation result contract and processor interfaces. - Introduce `MissingProcessorConfigException` for better error handling. - Replace `ValidationException` with more specific exception handling. - Update various processors (`LengthValidator`, `EmailValidator`, `UrlValidator`, etc.) to handle configuration properly. - Implement `DefaultValidationResultProcessor` for standardized result processing. - Adjust `DateFormatValidator` and `DateRangeValidator` to improve validation accuracy. - Remove legacy validation exception logic.
- Added tests to ensure Validate implements ProcessableAttribute and CustomizableMessageAttribute interfaces. - Verified that Validate can handle single and multiple processors, including processors with configurations. - Implemented tests for filtering invalid processors. - Added message handling tests to validate messages associated with specific processors. - Ensured compatibility with both configured and non-configured processors.
…alidator, and UrlValidator - Added unit tests for DateFormatValidator to validate default and custom date formats, along with invalid formats and data types. - Added unit tests for EmailValidator to validate correct email formats, handle invalid formats, and manage incorrect data types. - Implemented tests for LengthValidator to handle valid lengths, input that is too short or too long, and incorrect data types. Also covered missing or incomplete configuration cases. - Added unit tests for UrlValidator to check valid and invalid URL formats, as well as invalid data types.
- Added tests for ConditionalValidator to validate custom conditions and associated validation logic. - Included tests for cases where the condition is met or not met, and how it handles valid and invalid input. - Added unit tests for RequiredValidator to ensure that fields are correctly marked as required. - Covered cases for empty values, non-empty values, and handling different data types.
- Optimized IntegerValidator by refactoring the isValidInteger method to improve readability and efficiency. - Replaced multiple if statements with a single return expression for cleaner and more concise code. - Added IntegerValidatorTest to ensure correct handling of valid and invalid integers, including negative values and edge cases. - Updated ConditionalValidatorTest to ensure consistent testing for conditional logic.
… custom exceptions - Added DateValidatorException to handle invalid date format errors. - Refactored DateRangeValidator to use DateValidatorException and MissingProcessorConfigException for more consistent error handling. - Improved date parsing logic in DateRangeValidator to throw specific exceptions for missing configurations and invalid date formats. - Added unit tests for DateRangeValidator, covering valid and invalid date ranges, custom date formats, and error handling for missing configurations. - Added RangeValidatorTest to validate correct behavior of range validation for numeric values.
This commit adds comprehensive test coverage for the validator module: - DefaultValidationResultProcessorTest: Tests validation result processing including: - Valid data processing - Error handling - Multiple errors for same property - Empty property handling - Mixed valid/invalid property cases - ValidationResultTest: Tests validation result management including: - Error addition and retrieval - Validated data storage - State management - Data type handling - Array serialization - Duplicate error prevention - ValidatorTest: Tests core validator functionality including: - Object validation - Attribute processing - Error collection - Result generation - Integration with processors
- Created a new unit test for DateValidatorException to ensure proper validation error handling. - new file: tests/Exception/DateValidatorExceptionTest.php
- Modified the test to improve exception handling verification in DateRangeValidator. - modified: tests/Processor/Date/DateRangeValidatorTest.php
- English version with complete validator component documentation - Brazilian Portuguese translation with localized examples - Both versions include: - Detailed feature descriptions - Installation and usage guides - Available validators catalog - Configuration instructions - Development setup - Testing procedures - Integration guides
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.
IntegerValidator
andDateRangeValidator
to improve performanceDateValidatorException
and enhance exception handling in date validatorsValidate
attributeDateFormatValidator
,EmailValidator
,LengthValidator
ConditionalValidator
,RequiredValidator
DateValidatorException
andDateRangeValidator