Defer validation
This commit is contained in:
parent
f22dc98c23
commit
70b8303fdb
1 changed files with 8 additions and 5 deletions
|
@ -5,7 +5,6 @@ from django.core.validators import MaxValueValidator, MinValueValidator, RegexVa
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.forms.models import ModelForm, ModelFormMetaclass
|
from django.forms.models import ModelForm, ModelFormMetaclass
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from jsonschema import validate
|
|
||||||
|
|
||||||
from servala.core.models import ServiceInstance
|
from servala.core.models import ServiceInstance
|
||||||
|
|
||||||
|
@ -254,10 +253,14 @@ class CrdModelFormMixin:
|
||||||
|
|
||||||
def validate_nested_data(self, data, schema):
|
def validate_nested_data(self, data, schema):
|
||||||
"""Validate data against the provided OpenAPI v3 schema"""
|
"""Validate data against the provided OpenAPI v3 schema"""
|
||||||
try:
|
# TODO: actually validate the nested data.
|
||||||
validate(instance=data, schema=schema)
|
# TODO: get jsonschema to give us a path to the failing field rather than just an error message,
|
||||||
except Exception as e:
|
# then add the validation error to that field (self.add_error())
|
||||||
raise forms.ValidationError(f"Validation error: {e.message}")
|
# 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):
|
def generate_model_form_class(model):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue