In py file:
class DocType_name(Document):
def validate(doc):
mobile_number_validation(doc)
def mobile_number_validation(doc):
if doc.field_name:
if not (doc.field_name).isdigit():
frappe.throw(“Field Contact Number Accept Digits Only”)
if len(doc.field_name)>10:
frappe.throw(“Field Contact Number must be 10 Digits”)
if len(doc.field_name)<10:
frappe.throw(“Field Contact Number must be 10 Digits”)