Introduction
protected function casts(): array
{
return [
'name' => new StringCast(),
'age' => new IntegerCast(),
'created_at' => new CarbonImmutableCast(),
];
}use WendellAdriel\ValidatedDTO\Attributes\Cast;
use WendellAdriel\ValidatedDTO\Concerns\EmptyCasts;
class UserDTO extends ValidatedDTO
{
use EmptyCasts;
public string $name;
public string $email;
#[Cast(BooleanCast::class)]
public bool $active;
#[Cast(IntegerCast::class)]
public ?int $age;
#[Cast(type: ArrayCast::class, param: FloatCast::class)]
public ?array $grades;
}Last updated