From f8240372019b24fd58c326997c314ee8224457b0 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Sat, 2 Mar 2024 09:45:15 +0100 Subject: [PATCH] Remove validators --- backend/domain/validation/SubjectValidator.py | 21 ---------------- backend/domain/validation/TeacherValidator.py | 18 -------------- backend/domain/validation/ValidationResult.py | 24 ------------------- backend/requirements.txt | 2 ++ 4 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 backend/domain/validation/SubjectValidator.py delete mode 100644 backend/domain/validation/TeacherValidator.py delete mode 100644 backend/domain/validation/ValidationResult.py diff --git a/backend/domain/validation/SubjectValidator.py b/backend/domain/validation/SubjectValidator.py deleted file mode 100644 index 88b2a892..00000000 --- a/backend/domain/validation/SubjectValidator.py +++ /dev/null @@ -1,21 +0,0 @@ -from domain.validation.ValidationResult import ValidationError, ValidationResult, ValidationSuccess - - -class SubjectValidator: - @staticmethod - def validate(json_data: dict) -> ValidationResult: - - name = json_data.get("name") - teacher_id = json_data.get("teacher_id") - - errors: list[str] = [] - if not name: - errors.append("Veld 'name' ontbreekt.") - - if not teacher_id: - errors.append("Veld 'teacher_id' ontbreekt.") - - if len(errors) > 0: - return ValidationError(errors) - - return ValidationSuccess() diff --git a/backend/domain/validation/TeacherValidator.py b/backend/domain/validation/TeacherValidator.py deleted file mode 100644 index 0f57aa15..00000000 --- a/backend/domain/validation/TeacherValidator.py +++ /dev/null @@ -1,18 +0,0 @@ -from domain.validation.ValidationResult import ValidationError, ValidationResult, ValidationSuccess - - -# deze klassen zijn niet meer nodig omdat we gebruik maken van pydantic en FastAPI -class TeacherValidator: - @staticmethod - def validate(json_data: dict) -> ValidationResult: - - name = json_data.get("name") - - errors: list[str] = [] - if not name: - errors.append("Veld 'name' ontbreekt.") - - if len(errors) > 0: - return ValidationError(errors) - - return ValidationSuccess() diff --git a/backend/domain/validation/ValidationResult.py b/backend/domain/validation/ValidationResult.py deleted file mode 100644 index 3ffe7142..00000000 --- a/backend/domain/validation/ValidationResult.py +++ /dev/null @@ -1,24 +0,0 @@ -from abc import ABC, abstractmethod - - -class ValidationResult(ABC): - - errors: list[str] - - @abstractmethod - def __bool__(self) -> bool: - raise NotImplementedError - - -class ValidationSuccess(ValidationResult): - - def __bool__(self) -> bool: - return True - - -class ValidationError(ValidationResult): - def __init__(self, errors: list[str]) -> None: - self.errors = errors - - def __bool__(self) -> bool: - return False diff --git a/backend/requirements.txt b/backend/requirements.txt index 679534f5..dbd63a55 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,6 +1,8 @@ annotated-types==0.6.0 anyio==4.3.0 click==8.1.7 +dnspython==2.6.1 +email_validator==2.1.1 fastapi==0.110.0 greenlet==3.0.3 h11==0.14.0