Code Monkey home page Code Monkey logo

Comments (7)

Gummibeer avatar Gummibeer commented on May 20, 2024 1

Instead of your current

return $rules = [
    'translations.%name%' => 'required|string',
];

you just do

return RuleFactory::make([
    'translations.%name%' => 'required|string',
]);

It will still return an array but will parse it and replace the placeholders.

from laravel-translatable.

cvhainb avatar cvhainb commented on May 20, 2024 1

You're awesome! thank you so much.

from laravel-translatable.

turkidkil avatar turkidkil commented on May 20, 2024 1

This is true?

< input name="translations[en][name]" > ?
Because Validation Rule did not work for me!

      $rules = [
           'translations.%name%' => ['required_without:translations.%name%', 'nullable', 'min:3', 'max:50'],
       ];

       RuleFactory::make($rules);
       $request->validate($rules);
....

from laravel-translatable.

Gummibeer avatar Gummibeer commented on May 20, 2024

Hey,

you have to wrap your $rules array in the RuleFactory::make($rules);. This will replace your placeholder with all locale field combinations you have configured.

For further details please check the docs:
https://docs.astrotomic.info/laravel-translatable/package/validation-rule-factory

from laravel-translatable.

cvhainb avatar cvhainb commented on May 20, 2024

Dear Gummibeer,

Thank you for replied. Yes, I have read it some times and try to learn more about laravel validation but it's not lucky for me. I'm a newbie. Is there example about this? If you have one, please send me the URL.

from laravel-translatable.

Gummibeer avatar Gummibeer commented on May 20, 2024

Thanks! :)
Is there anything we could improve in the docs? Writing docs as the maintainer is every time hard because I don't now which could be unknown or has to explained better with an example.

from laravel-translatable.

cvhainb avatar cvhainb commented on May 20, 2024

I think it's better if you have a few examples how to do that because it's more easier for newbie, like me.

I have fixed the problem. Thank you so much ^^!

from laravel-translatable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.