20 lines
635 B
Python
20 lines
635 B
Python
|
|
from tortoise.exceptions import ValidationError
|
|
from tortoise.validators import Validator
|
|
import typing
|
|
from services.exoValidation import get_support_from_data
|
|
|
|
class ExoSourceValidator(Validator):
|
|
"""
|
|
A validator to validate ...
|
|
"""
|
|
|
|
def __call__(self, value: typing.IO):
|
|
exo_supports_compatibility = get_support_from_data(
|
|
value.read())
|
|
if not exo_supports_compatibility['isPdf'] and not exo_supports_compatibility['isCsv'] and not exo_supports_compatibility['isWeb']:
|
|
raise ValidationError(
|
|
'[Error] : Exercice non valide (compatible avec aucun support)')
|
|
|
|
|