'check if IP Address is valid'

def validate_ip_address(self):

    ip_list = frappe.db.get_value(u'User', self.user, u'restrict_ip', ignore=True)
    if (not ip_list):
        return
    ip_list = ip_list.replace(u',', u'\n').split(u'\n')
    ip_list = [i.strip() for i in ip_list]
    for ip in ip_list:
        if frappe.local.request_ip.startswith(ip):
            return
    frappe.throw(_(u'Not    allowed    from    this    IP    Address'), frappe.AuthenticationError)
