function securitytxt_file_form_validate in Security.txt 7
Security.txt file form validation.
File
- ./
securitytxt.admin.inc, line 99
Code
function securitytxt_file_form_validate($form, &$form_state) {
$enabled = $form_state['values']['enabled'];
$contact_email = $form_state['values']['contact_email'];
$contact_phone = $form_state['values']['contact_phone'];
$contact_url = $form_state['values']['contact_url'];
$encryption_key_url = $form_state['values']['encryption_key_url'];
$policy_url = $form_state['values']['policy_url'];
$acknowledgement_url = $form_state['values']['acknowledgement_url'];
if ($contact_email != '' && valid_email_address($contact_email) == FALSE) {
form_set_error('contact_email', t('The contact email address in invalid.'));
}
if ($contact_phone != '' && _securitytxt_valid_phone($contact_phone) == FALSE) {
form_set_error('contact_phone', t('The contact phone number is invalid.'));
}
if ($contact_url != '' && valid_url($contact_url, TRUE) == FALSE) {
form_set_error('contact_url', t('The contact URL is invalid, please ensure that it is an absolute URL.'));
}
/* When enabled, check that at least one contact field is specified. */
if ($enabled && $contact_email == '' && $contact_phone == '' && $contact_url == '') {
form_set_error('contact', t('You must specify at least one method of contact.'));
}
if ($encryption_key_url != '' && valid_url($encryption_key_url, TRUE) == FALSE) {
form_set_error('encryption_key_url', t('The encryption key URL is invalid, please ensure that it is an absolute URL.'));
}
if ($policy_url != '' && valid_url($policy_url, TRUE) == FALSE) {
form_set_error('policy_url', t('The policy URL is invalid, please ensure that it is an absolute URL.'));
}
if ($acknowledgement_url != '' && valid_url($acknowledgement_url, TRUE) == FALSE) {
form_set_error('acknowledgement_url', t('The acknowledgement URL is invalid, please ensure that it is an absolute URL.'));
}
}