for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Chubbyphp\ApiSkeleton\Validation;
use Chubbyphp\Model\ResolverInterface;
use Chubbyphp\Validation\Constraint\ConstraintInterface;
use Chubbyphp\Validation\Constraint\NotBlankConstraint;
use Chubbyphp\Validation\Constraint\NotNullConstraint;
use Chubbyphp\Validation\Mapping\ObjectMappingInterface;
use Chubbyphp\Validation\Mapping\PropertyMapping;
use Chubbyphp\Validation\Mapping\PropertyMappingInterface;
use Chubbyphp\ApiSkeleton\Model\Document;
use Chubbyphp\ValidationModel\Constraint\UniqueModelConstraint;
final class DocumentMapping implements ObjectMappingInterface
{
/**
* @var ResolverInterface
*/
private $resolver;
* @param ResolverInterface $resolver
public function __construct(ResolverInterface $resolver)
$this->resolver = $resolver;
}
* @return string
public function getClass(): string
return Document::class;
* @return ConstraintInterface[]
public function getConstraints(): array
return [new UniqueModelConstraint($this->resolver, ['courseId', 'name'])];
* @return PropertyMappingInterface[]
public function getPropertyMappings(): array
return [
new PropertyMapping('name', [new NotNullConstraint(), new NotBlankConstraint()]),
new PropertyMapping('url', [new NotNullConstraint(), new NotBlankConstraint()]),
];