Replies: 1 comment
-
Hi @ragulka, To be honest, I have no idea how we could solve such an issue. Technically something could be said that when data is created with an already initialized data object that the object is probably fine and shouldn't need extra validation. But I'm not sure that's completely correct and something we could only add in major version which will take probably yet another year. For now I use this paragraph from the docs 😄:
|
Beta Was this translation helpful? Give feedback.
-
As mentioned in another discussion, I am looking to recreate how Stripe handles ids and objects. Basically, I want the DTO to accept either a tax ID as string, or a full TaxData object.
I have added the
TaxData::fromString
magic creation method, which fetches the Tax model from the DB and populates the data object, so I can do something likeProductData::from(['name' => 'Foo', 'tax' => 'some_tax_id' ]);
- which works great.However, it looks like there is no way to skip TaxData validation for the
tax
property. Since I am validating thetax
property myself to be a valid ID for a Tax model, and I am loading the data from the DB anyway, I don't need to validate things liketax.name
, etc.It seems that currently it's only possible to turn off validation for a property wholesale using
WithoutValidation
attribute.Perhaps there is some way (and if not, consider this a suggestion) to only skip validation for nested data objects, while keeping the top-level validation rules for the property?
Or perhaps there is a workaround I could leverage? Ie, filling in the nested object in the payload before validating the nested DTO?
Beta Was this translation helpful? Give feedback.
All reactions