Astrotomic / laravel-translatable

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

Support different validation rules for different locales #248

Closed Eyad-Bereh closed 2 years ago

Eyad-Bereh commented 2 years ago

First of all, i would like to say thanks for the maintainer and contributors of this great package

Let's say i want to generate different validation rules for different locales using RuleFactory

For example, i want to make the fields in Arabic required while leaving them optional for the English version

Is this possible in the current time or not ?, how can i achieve this ?

Gummibeer commented 2 years ago

Hey,

with one rule factory it isn't. But you could use multiple with a different set of locales and rules and merge the resulting Arrays.

Or you hardcode your additional locale and rule and use array_merge_recursive() to add the additional rule to the primary locale.

At the end you will have to add/merge your rules manually.

Eyad-Bereh commented 2 years ago

@Gummibeer Sounds like a good idea Thank you very much