<?php
use Chubbyphp\Validation\Constraint\FalseConstraint;
use Chubbyphp\Validation\ValidatorContextInterface;
$constraint = new FalseConstraint();
/** @var ValidatorContextInterface $context */
$context = ...;
// Use NotNullConstraint to prevent null
$errors = $constraint->validate(
'path.to.property',
null,
$context
);
// [];
$errors = $constraint->validate(
'path.to.property',
false,
$context
);
// [];
$errors = $constraint->validate(
'path.to.property',
true,
$context
);
// [
// new Error(
// 'path.to.property',
// 'constraint.false.notfalse'
// )
// ];
$errors = $constraint->validate(
'path.to.property',
'',
$context
);
// [
// new Error(
// 'path.to.property',
// 'constraint.false.notfalse'
// )
// ];
$errors = $constraint->validate(
'path.to.property',
[],
$context
);
// [
// new Error(
// 'path.to.property',
// 'constraint.false.notfalse'
// )
// ];
$errors = $constraint->validate(
'path.to.property',
new \stdClass,
$context
);
// [
// new Error(
// 'path.to.property',
// 'constraint.false.notfalse'
// )
// ];
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.