Skip to content
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

Enhance Custom Rules: Introduce translatableExists and translatableUnique for Validating Translatable Attributes #406

Merged
merged 7 commits into from
Aug 26, 2024

Conversation

amjadbanimattar
Copy link
Contributor

Description:
Incorporating unique and existence validation for translatable attributes can be crucial for many projects. The current Laravel validation doesn't inherently support this functionality, prompting the need for custom solutions.

This pull request introduces two custom validation rules, translatableExists, and translatableUnique, tailored specifically for validating translatable attributes. With these additions, developers gain the ability to ensure data integrity and uniqueness within multilingual datasets effortlessly.

Changes:
Added translatableExists rule to validate the existence of translatable attributes.
Introduced translatableUnique rule for enforcing uniqueness constraints on translatable fields.

Purpose:
This enhancement empowers developers to perform comprehensive validation on translatable attributes, enhancing data validation capabilities within multilingual contexts. By providing these custom rules, we aim to streamline development workflows and promote best practices in data validation.

Benefits:
Facilitates validation of translatable attributes for existence and uniqueness.
Enhances data integrity and consistency within multilingual datasets.
Provides developers with versatile tools for enforcing validation rules tailored to translatable fields.

Usage:
Developers can now utilize the translatableExists and translatableUnique rules in Laravel validation logic to ensure data integrity and uniqueness across multilingual attributes effortlessly.

Copy link
Member

@Gummibeer Gummibeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far looking okay - in addition to the requested changes please run the composer fix command locally to fix all the style changes.

README.md Outdated Show resolved Hide resolved
src/Translatable/Validation/Rules/TranslatableExists.php Outdated Show resolved Hide resolved
src/Translatable/Validation/Rules/TranslatableExists.php Outdated Show resolved Hide resolved
src/Translatable/Validation/Rules/TranslatableExists.php Outdated Show resolved Hide resolved
src/Translatable/Validation/Rules/TranslatableExists.php Outdated Show resolved Hide resolved
src/Translatable/Validation/Rules/TranslatableUnique.php Outdated Show resolved Hide resolved
- Fix PHPDocs, and Code Style
@amjadbanimattar
Copy link
Contributor Author

So far looking okay - in addition to the requested changes please run the composer fix command locally to fix all the style changes.

All request changes fixed, and pushed.

.gitignore Outdated Show resolved Hide resolved
@Gummibeer
Copy link
Member

Tests seem to fail for Laravel 9

… InvokableRule interface instead of the new one introduced in Laravel 10. Future updates will accommodate the removal of Laravel 9 support.
@amjadbanimattar
Copy link
Contributor Author

Tests seem to fail for Laravel 9

Apologies, @Gummibeer, I hadn't realized the compatibility issue with Laravel 9.

The code has been updated to accommodate Laravel 9, but it will require further refinement once Laravel 9 is no longer supported.

@amjadbanimattar amjadbanimattar requested a review from Gummibeer May 1, 2024 18:01
Copy link
Member

@Gummibeer Gummibeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for the delay - life's not easy with a toddler. 😂
Have a few smaller comments - mainly about the documentation.

docs/usage/custom-validation-rule.md Outdated Show resolved Hide resolved
docs/usage/custom-validation-rule.md Outdated Show resolved Hide resolved
docs/usage/custom-validation-rule.md Show resolved Hide resolved
src/Translatable/Locales.php Outdated Show resolved Hide resolved
Copy link
Member

@Gummibeer Gummibeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank! 🙏
One little note from my side for future PRs: adding all the doc-tags with type-hints here was the main reason why it took so long for me to review. And I still don't feel 100% confident. I love that you added them to improve autocompletion and IDe support etc. but would have liked it better to add them in a dedicated PR. They aren't really related to the feature but I had to check them to make your feature pass.
Keep your PRs more granular and separated makes it a lot easier to review them and if needed merge one while the other remains open.

@Gummibeer Gummibeer merged commit ad6369d into Astrotomic:main Aug 26, 2024
2 checks passed
@Gummibeer
Copy link
Member

@Gummibeer Gummibeer mentioned this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants