Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 727 Bytes

existence-constraint.md

File metadata and controls

26 lines (22 loc) · 727 Bytes

API resource existence constraint

Motivation

Sometimes, resources of a microservice A depends on resource of a microservice B. Then you may need to ensure that related resources are existing when validating a resource.

Description

The ApiResourceExist constraint helps you to ensure that the related resources are existing on the other microservice when doing validation. It can verify either IRIs and list of IRIs.

Example

use Mtarld\ApiPlatformMsBundle\Validator\ApiResourceExist;

class Order
{
    /**
     * @var list<string>
     */
    #[ApiResourceExist('product')]
    public array $products;

    #[ApiResourceExist(microservice: 'client', skipOnError: true)]
    public string $customer;
}