[minor] validate select default is in options

This commit is contained in:
Rushabh Mehta 2015-05-05 18:03:22 +05:30
parent 5bbe43ff78
commit 3e82f73672

View file

@ -265,6 +265,8 @@ def validate_fields(meta):
def check_illegal_default(d):
if d.fieldtype == "Check" and d.default and d.default not in ('0', '1'):
frappe.throw(_("Default for 'Check' type of field must be either '0' or '1'"))
if d.fieldtype == "Select" and d.default and (d.default not in d.options.split("\n")):
frappe.throw(_("Default for {0} must be an option").format(d.fieldname))
def check_precision(d):
if d.fieldtype in ("Currency", "Float", "Percent") and d.precision is not None and not (1 <= cint(d.precision) <= 6):