Create Your Own Type Cast
Castable classes
You can easily create new Castable
types for your project by implementing the WendellAdriel\ValidatedDTO\Casting\Castable
interface. This interface has a single method that must be implemented:
Let's say that you have a URLWrapper
class in your project, and you want that when passing a URL into your DTO
it will always return a URLWrapper
instance instead of a simple string:
Then you could apply this to your DTO:
Callable casts
You can also create new Castable
types for your project by using a callable/callback
:
Last updated