I’m new to API Platform and I want to ask if there’s a way to conditionally require an attribute of an entity. For example, I have an entity User with two attributes, HasCar and CarModel. CarModel will only be required if HasCar = true
This is my user class example but I’m not sure how to go forward with a conditional required property
class User {
#[ORMColumn('name: HasCar')]
private bool $hasCar = '';
#[ORMColumn('name: CarModel')]
*#[ApiProperty(required:true)] only if $hasCar = true*
private string $carModel = '';
}