Skip to content

Commit

Permalink
Server-validate required field
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffersonBledsoe committed Apr 2, 2024
1 parent 976e0f0 commit d5e052f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ def validate(self):
# Making sure we've got a validation that actually exists.
if not self._value and not self.required:
return
errors = {}

if self.required and not self.internal_value:
errors['required'] = 'This field is required'

available_validations = [
validation
for validationId, validation in getValidations()
if validationId in self.validations.keys()
]

errors = {}
for validation in available_validations:
error = validation(self._value, **self.validations.get(validation._name))
if error:
Expand Down

0 comments on commit d5e052f

Please sign in to comment.