Using built in validators with ModelForm

Hello. When using forms.Form, you can apply server side validation by using built in validators from Django.core.validators on form fields, e.g MinLengthValidator. Please correct me if I’m wrong.

How would I apply these validators on fields on a model form, so a validation error would be raised just like if they were applied on forms.Form?

Will applying them on the model fields themselves work, or will I have to accomplish this another way? Thanks.

You can apply validators to model form fields by defining the field within your form. See Overriding the default fields, specifically starting from the paragraph immediately above the code snippet above the first “Note” block in that segment. (The Note block is also worth reading in this case.)

Ken