Defer validation

This commit is contained in:
Tobias Kunze 2025-03-31 13:52:44 +02:00
parent f22dc98c23
commit 70b8303fdb

View file

@ -5,7 +5,6 @@ from django.core.validators import MaxValueValidator, MinValueValidator, RegexVa
from django.db import models
from django.forms.models import ModelForm, ModelFormMetaclass
from django.utils.translation import gettext_lazy as _
from jsonschema import validate
from servala.core.models import ServiceInstance
@ -254,10 +253,14 @@ class CrdModelFormMixin:
def validate_nested_data(self, data, schema):
"""Validate data against the provided OpenAPI v3 schema"""
try:
validate(instance=data, schema=schema)
except Exception as e:
raise forms.ValidationError(f"Validation error: {e.message}")
# TODO: actually validate the nested data.
# TODO: get jsonschema to give us a path to the failing field rather than just an error message,
# then add the validation error to that field (self.add_error())
# try:
# validate(instance=data, schema=schema)
# except Exception as e:
# raise forms.ValidationError(f"Validation error: {e.message}")
pass
def generate_model_form_class(model):