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

Latest commit

 

History

History
76 lines (66 loc) · 1.21 KB

FalseConstraint.md

File metadata and controls

76 lines (66 loc) · 1.21 KB

FalseConstraint

<?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'
//     )
// ];