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

Latest commit

 

History

History
32 lines (26 loc) · 529 Bytes

NotNullConstraint.md

File metadata and controls

32 lines (26 loc) · 529 Bytes

NotNullConstraint

<?php

use Chubbyphp\Validation\Constraint\NotNullConstraint;
use Chubbyphp\Validation\ValidatorContextInterface;

$constraint = new NotNullConstraint();

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

$errors = $constraint->validate(
    'path.to.property',
    '',
    $context
);
// [];

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