Coder Social home page Coder Social logo

Comments (5)

themsaid avatar themsaid commented on May 3, 2024

This is quite interesting, specially with the case of conditionally changing parameters.

Currently this is very unreadable:

'email' => 'email|unique:users,email'.($item ? ",$item->id" : ''),

Having an way of adding/updating rules parameters can make the validation code more readable. I'm planning to propose some changes to the validator in 5.3 and I believe adding this option is very useful.

from ideas.

franzliedke avatar franzliedke commented on May 3, 2024

Not sure if you already know, but passing rules for a field as an array instead of separating them by pipes is already possible.

So, to get what you want, a simple helper function that returns an array of rule parameters into a stringified rule would be enough.

from ideas.

franzliedke avatar franzliedke commented on May 3, 2024

passing rules for a field as an array instead of separating them by pipes is already possible

This part isn't really explained in the docs, except for a small mention in the regex rule (because it's the only workaround for using pipes in regexes).

from ideas.

amitailanciano avatar amitailanciano commented on May 3, 2024

I am aware that it is possible to define rules as an array, but to my knowledge it is not possible to define their parameters in the same manner -- I mentioned in my OP that a helper could be used for that, sure -- however it is tedious and cumbersome, and it does not address or resolve points 2 or 3, and point 4 without some manually work in between the final rules being returned

from ideas.

taylorotwell avatar taylorotwell commented on May 3, 2024

I think this was essentially solved with introduced of fluent syntax for rules.

from ideas.

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.