Errors
1 year ago
Exceptions
1 year ago
Filters
1 year ago
Formats
1 year ago
Info
1 year ago
KeywordValidators
1 year ago
Keywords
1 year ago
Parsers
1 year ago
Pragmas
1 year ago
Resolvers
1 year ago
Schemas
1 year ago
Variables
1 year ago
CompliantValidator.php
1 year ago
ContentEncoding.php
1 year ago
ContentMediaType.php
1 year ago
Filter.php
1 year ago
Format.php
1 year ago
Helper.php
1 year ago
JsonPointer.php
1 year ago
Keyword.php
1 year ago
KeywordValidator.php
1 year ago
Pragma.php
1 year ago
Schema.php
1 year ago
SchemaLoader.php
7 months ago
SchemaValidator.php
1 year ago
Uri.php
1 year ago
ValidationContext.php
7 months ago
ValidationResult.php
1 year ago
Validator.php
1 year ago
Variables.php
1 year ago
ValidationResult.php
53 lines
| 1 | <?php |
| 2 | /* ============================================================================ |
| 3 | * Copyright 2021 Zindex Software |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * ============================================================================ */ |
| 17 | |
| 18 | namespace Opis\JsonSchema; |
| 19 | |
| 20 | use Opis\JsonSchema\Errors\ValidationError; |
| 21 | |
| 22 | class ValidationResult |
| 23 | { |
| 24 | protected ?ValidationError $error; |
| 25 | |
| 26 | public function __construct(?ValidationError $error) |
| 27 | { |
| 28 | $this->error = $error; |
| 29 | } |
| 30 | |
| 31 | public function error(): ?ValidationError |
| 32 | { |
| 33 | return $this->error; |
| 34 | } |
| 35 | |
| 36 | public function isValid(): bool |
| 37 | { |
| 38 | return $this->error === null; |
| 39 | } |
| 40 | |
| 41 | public function hasError(): bool |
| 42 | { |
| 43 | return $this->error !== null; |
| 44 | } |
| 45 | |
| 46 | public function __toString(): string |
| 47 | { |
| 48 | if ($this->error) { |
| 49 | return $this->error->message(); |
| 50 | } |
| 51 | return ''; |
| 52 | } |
| 53 | } |