# SPDX-FileCopyrightText: Copyright © 2026 BBC
#
# SPDX-License-Identifier: BSD-3-Clause
from dataclasses import dataclass
from .validationCodes import ValidationCode
GOOD = 0
"""Validation status code for a passed check, content is valid"""
INFO = 1
"""Validation status code for information generated by a check"""
WARN = 2
"""Validation status code for a warning generated by a check"""
ERROR = 3
"""Validation status code for a failed check, content is invalid"""
SKIP = 4
"""Validation status code for skipped check"""
StatusStrings = {
GOOD: 'Success',
INFO: 'Information',
WARN: 'Warning',
ERROR: 'Error',
SKIP: 'Skip',
}
"""
Map of Validation status codes to human readable strings
"""
[docs]
@dataclass
class ValidationResult:
status: int
location: str
message: str
code: ValidationCode | None = None
def _getCode(self) -> str:
return \
self.code.name if self.code \
else ValidationCode.unclassified.name
[docs]
def asString(self) -> str:
return '{status}: {code} {location} {message}'.format(
status=StatusStrings.get(self.status, 'UNKNOWN'),
code=self._getCode(),
location=self.location,
message=self.message,
)
[docs]
def asDict(self) -> dict:
return {
'status': self.status,
'location': self.location,
'message': self.message,
'code': self._getCode(),
}