Coder Social home page Coder Social logo

Comments (2)

rubenvanassche avatar rubenvanassche commented on August 29, 2024 3

We run a complete pipeline (so getting the data ready for building the data object) before we run the magic creation method when it has a request tyepd parameter. This to make sure the data you're working with is valid. So in this case we've validated the data before we ran the pipeline and thus a validation exception is thrown.

Take a look here: https://spatie.be/docs/laravel-data/v2/advanced-usage/pipeline

You can add extra properties before the pipeline, the problem is. That in the end we throw all this data away and just pass in the request because our pipeline generates an array of data and not a request. So you still would have to define the default in the magic creation method.

I'm not entirely sure if that's the best solution, since this is the second time someone runs into such a problem today. But if we don't run the pipeline somewhere on the request nothing would be validated and that's a bigger problem.

A solution could be to run a minimal validation pipeline on the data object after creating it and then send out a validation exception if something goes wrong. But our complete validation logic has been built around the fact that no data object exists. Maybe that's something which needs to change in v3. But this opens also a lot of problems, what if we want to put an int into a data object property. This would crash completely. Stuff to think about ....

from laravel-data.

denjaland avatar denjaland commented on August 29, 2024

Thanks for the feedback, @rubenvanassche. Much appreciated.

I can easily change it by duplicating the Data object into a PasswordResetData object and a CreatePasswordResetData object, but I'd like to avoid that, as we have MANY of such redundant Request objects currently. If we are going to refactor this, we do it good :-)

from laravel-data.

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.