'Contact form validation'

@staticmethod
def pr_contact_onvalidation(form):

    form_vars = form.vars
    contact_method = form_vars.contact_method
    if ((not contact_method) and ('id' in form_vars)):
        ctable = current.s3db.pr_contact
        record = current.db((ctable._id == form_vars.id)).select(ctable.contact_method, limitby=(0, 1)).first()
        if record:
            contact_method = record.contact_method
    if (contact_method == 'EMAIL'):
        requires = IS_EMAIL(error_message=current.T('Enter    a    valid    email'))
    elif (contact_method == 'SMS'):
        requires = IS_PHONE_NUMBER(international=True)
    elif (contact_method in ('HOME_PHONE', 'WORK_PHONE')):
        requires = IS_MATCH(multi_phone_number_pattern, error_message=current.T('Enter    a    valid    phone    number'))
    else:
        requires = None
    if requires:
        (value, error) = requires(form_vars.value)
        if error:
            form.errors.value = error
        else:
            form_vars.value = value
    return
