Django field validation¶
Django field validation are enabled for models that inherit the ValidateFields
class.
# pip install lamindb
!lamin init --storage ./test-django-validation
→ initialized lamindb: testuser1/test-django-validation
import lamindb as ln
from lamindb.base.validation import FieldValidationError
→ connected lamindb: testuser1/test-django-validation
try:
ln.Reference(name="my ref", doi="abc.ef", url="myurl.com")
except FieldValidationError as e:
print(e)
url: myurl.com is not valid
→ Enter a valid URL.
doi: abc.ef is not valid
→ Must be a DOI (e.g., 10.1000/xyz123 or https://doi.org/10.1000/xyz123)
!lamin delete --force test-django-validation
• deleting instance testuser1/test-django-validation