You can add validation inside the validate function of your DocType’s Python class.
# student.py
import frappe
from frappe.model.document import Document
class Student(Document):
def validate(self):
if not self.email.endswith("@example.com"):
frappe.throw("Only '@example.com' email addresses are allowed.")