Code Monkey home page Code Monkey logo

Comments (10)

kocsismate avatar kocsismate commented on June 1, 2024 2

Maybe also pass the JsonApiRequestInterface $request to validateDomainObject. I don't have a case now where I would need the request, but if something is in the request, but it's not in the DomainObject... maybe I this is a step to far

Huh, although I think it's really a bit too much of overengineering, I'm ok to add it (e.g. CreateHydratorTrait::validateClientGeneratedId() already does something similar). And I've just realized that the Exception Factory should be added as well. Unfortunately, I missed to add it to validateRequest() (or maybe it has a reason I forgot). However, as I've already started to work on v5.0, I'm going to fix this inconsistency issue there.

To merge my requests (internal work projects) I would need this to be released to a stable version first... I guess it won't take long before it's tagged :)?

I have to wait a little bit for another feedback (#103), but I can release the next version soon if everything goes well.

from yin.

kocsismate avatar kocsismate commented on June 1, 2024 1

I've just release 4.3.0 including the validation of the domain object. :)

from yin.

Ilyes512 avatar Ilyes512 commented on June 1, 2024

So I made a fork and made the changes needed to solve my current issue: master...signet-connectivity:pass-object-to-validator

I guess its a backwards incompatible change. I could solve this without making these changes, but I would have to copy/paste some of the trait methods.

I think in the end that it's hard to extend/reuse AbstractHydrator because of the traits here.

The traits are both an implementation and a contract. I think separating just that would make things easier to extend.

from yin.

kocsismate avatar kocsismate commented on June 1, 2024

Hi @Ilyes512

Sorry for not not replying so long. I'll carve out some free time for Yin this week so that I can look into the open tickets.

from yin.

Ilyes512 avatar Ilyes512 commented on June 1, 2024

No problem :) BTW, I am also no a 100% sure if this is the way to go.

from yin.

kocsismate avatar kocsismate commented on June 1, 2024

Can you please tell me why the $domainObject is needed for validation? Does it have more information besides the data from the request?

Regarding the BC impact, I have a possible idea: we could add a new UpdateHydratorTrait::validateDomainObject() method which would be called after request validation. I like this idea because request validation was separated from the object validation this way, but I'm curious if it would work for your use-case?

from yin.

Ilyes512 avatar Ilyes512 commented on June 1, 2024

Does it have more information besides the data from the request?

Yes. So what I have is an entity that has 2 attributes, limit and maxLimit. Users are able to adjust limit between 0 and maxLimit. Where maxLimit is different for each entity (dynamic), but not configurable by the user (it is set and updated by another service).

Regarding your solution... I think that will work in my case. First check that the received limit is an int and higher than 0. And after that, validate if it's lower than the maxLimit.

The validateDomainObject.... would it receive the object before or after being hydrated (after going through getAttributeHydrator)?.

from yin.

kocsismate avatar kocsismate commented on June 1, 2024

Thanks for the quick answers!

The validateDomainObject.... would it receive the object before or after being hydrated (after going through getAttributeHydrator)?.

My idea is to run validateDomainObject() after it has been hydrated

from yin.

kocsismate avatar kocsismate commented on June 1, 2024

I added e55ee84. Can you please test it?

from yin.

Ilyes512 avatar Ilyes512 commented on June 1, 2024

Yes! I tested this out on my actual problem... and it works for my case :).

Just one remark (cause now it wouldn't be backwards imcompatible). Maybe also pass the JsonApiRequestInterface $request to validateDomainObject. I don't have a case now where I would need the request, but if something is in the request, but it's not in the DomainObject... maybe I this is a step to far ¯_(ツ)_/¯

To merge my requests (internal work projects) I would need this to be released to a stable version first... I guess it won't take long before it's tagged :)?

from yin.

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.