feat(models): add validators for VPN port range
Added MinValueValidator and MaxValueValidator for the port field in the VPN model to ensure values are between 10000 and 40000. This change enforces port number constraints directly in the model, preventing invalid entries and improving data integrity.
This commit is contained in:
parent
e1bf6b9901
commit
c7c05f2677
1 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
|
@ -16,7 +17,10 @@ class VPN(models.Model):
|
|||
owner = models.ForeignKey(get_user_model(), models.CASCADE)
|
||||
name = models.CharField(max_length=128)
|
||||
port = models.IntegerField(
|
||||
unique=True, min_value=10000, max_value=40000, null=True, blank=True
|
||||
unique=True,
|
||||
null=True,
|
||||
blank=True,
|
||||
validators=[MinValueValidator(10000), MaxValueValidator(40000)],
|
||||
)
|
||||
private_key = EncryptedCharField(max_length=128, null=True, blank=True)
|
||||
public_key = models.CharField(max_length=128, null=True, blank=True)
|
||||
|
|
Loading…
Reference in a new issue