Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Latest commit

 

History

History
38 lines (31 loc) · 652 Bytes

ValidConstraint.md

File metadata and controls

38 lines (31 loc) · 652 Bytes

ValidConstraint

<?php

use Chubbyphp\Validation\Constraint\ValidConstraint;
use Chubbyphp\Validation\ValidatorContextInterface;
use Chubbyphp\Validation\ValidatorInterface;

$constraint = new ValidConstraint();

/** @var ValidatorContextInterface $context */
$context = ...;

/** @var ValidatorInterface $validator */
$validator = ...;

$model = new class()
{
    /**
     * @var string
     */
    private $name;
};

$errors = $constraint->validate(
    'path.to.property',
    [$model],
    $context,
    $validator
);
// [
//     new Error(
//         "path.to.property[0]['name']",
//         'constraint.notnull.null'
//     )
// ];