|
| 1 | +from typing import Any, List, Optional |
| 2 | + |
1 | 3 | from ...exceptions import InvalidEnvelopeExpressionError
|
2 | 4 |
|
3 | 5 |
|
4 | 6 | class SchemaValidationError(Exception):
|
5 | 7 | """When serialization fail schema validation"""
|
6 | 8 |
|
| 9 | + def __init__( |
| 10 | + self, |
| 11 | + message: str, |
| 12 | + validation_message: Optional[str] = None, |
| 13 | + name: Optional[str] = None, |
| 14 | + path: Optional[List] = None, |
| 15 | + value: Optional[Any] = None, |
| 16 | + definition: Optional[Any] = None, |
| 17 | + rule: Optional[str] = None, |
| 18 | + rule_definition: Optional[Any] = None, |
| 19 | + ): |
| 20 | + """ |
| 21 | +
|
| 22 | + Parameters |
| 23 | + ---------- |
| 24 | + message : str |
| 25 | + Powertools formatted error message |
| 26 | + validation_message : str, optional |
| 27 | + Containing human-readable information what is wrong (e.g. ``data.property[index] must be smaller than or |
| 28 | + equal to 42``) |
| 29 | + name : str, optional |
| 30 | + name of a path in the data structure (e.g. ``data.property[index]``) |
| 31 | + path: List, optional |
| 32 | + ``path`` as an array in the data structure (e.g. ``['data', 'property', 'index']``), |
| 33 | + value : Any, optional |
| 34 | + the invalid value |
| 35 | + definition : Any, optional |
| 36 | + The full rule ``definition`` (e.g. ``42``) |
| 37 | + rule : str, optional |
| 38 | + `rule`` which the ``data`` is breaking (e.g. ``maximum``) |
| 39 | + rule_definition : Any, optional |
| 40 | + The full rule ``definition`` (e.g. ``42``) |
| 41 | + """ |
| 42 | + super().__init__(message) |
| 43 | + self.message = message |
| 44 | + |
| 45 | + self.validation_message = validation_message |
| 46 | + self.name = name |
| 47 | + self.path = path |
| 48 | + self.value = value |
| 49 | + self.definition = definition |
| 50 | + self.rule = rule |
| 51 | + self.rule_definition = rule_definition |
| 52 | + |
7 | 53 |
|
8 | 54 | class InvalidSchemaFormatError(Exception):
|
9 | 55 | """When JSON Schema is in invalid format"""
|
|
0 commit comments