1<?php 2 3/* 4 * This file is part of the JsonSchema package. 5 * 6 * For the full copyright and license information, please view the LICENSE 7 * file that was distributed with this source code. 8 */ 9 10namespace JsonSchema\Constraints; 11 12use JsonSchema\Entity\JsonPointer; 13 14/** 15 * The Constraints Interface 16 * 17 * @author Robert Schönthal <seroscho@googlemail.com> 18 */ 19interface ConstraintInterface 20{ 21 /** 22 * returns all collected errors 23 * 24 * @return array 25 */ 26 public function getErrors(); 27 28 /** 29 * adds errors to this validator 30 * 31 * @param array $errors 32 */ 33 public function addErrors(array $errors); 34 35 /** 36 * adds an error 37 * 38 * @param JsonPointer|null $path 39 * @param string $message 40 * @param string $constraint the constraint/rule that is broken, e.g.: 'minLength' 41 * @param array $more more array elements to add to the error 42 */ 43 public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null); 44 45 /** 46 * checks if the validator has not raised errors 47 * 48 * @return bool 49 */ 50 public function isValid(); 51 52 /** 53 * invokes the validation of an element 54 * 55 * @abstract 56 * 57 * @param mixed $value 58 * @param mixed $schema 59 * @param JsonPointer|null $path 60 * @param mixed $i 61 * 62 * @throws \JsonSchema\Exception\ExceptionInterface 63 */ 64 public function check(&$value, $schema = null, JsonPointer $path = null, $i = null); 65} 66