Astrotomic / laravel-translatable

A Laravel package for multilingual models
https://docs.astrotomic.info/laravel-translatable/
MIT License
1.22k stars 152 forks source link

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

Open amjadbanimattar opened 2 months ago

amjadbanimattar commented 2 months ago

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.

amjadbanimattar commented 2 months ago

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.

Gummibeer commented 2 months ago

Tests seem to fail for Laravel 9

amjadbanimattar commented 2 months ago

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.