use woocommerce validation

This commit is contained in:
Bilal Catic
2018-11-22 11:27:30 +01:00
parent 68c760a426
commit 8d954469ee
2 changed files with 4 additions and 5 deletions

View File

@@ -9,18 +9,17 @@ class Wiaas_Admin_Profile {
}
function crf_user_profile_update_errors( $errors, $update, $user ) {
public static function crf_user_profile_update_errors( $errors, $update, $user ) {
$phone = $_POST['phone'];
if (!preg_match('/^[\d +]*$/', $phone)){
if (!WC_Validation::is_phone($phone)){
$errors->add('phone_error', __( '<strong>ERROR</strong>: Enter valid phone number.', 'crf' ));
};
}
function modify_user_contact_methods($user_contact){
public static function modify_user_contact_methods($user_contact){
$user_contact['phone'] = __( 'Phone number' );
return $user_contact;

View File

@@ -148,7 +148,7 @@ class Wiaas_REST_Customer_API {
return wiaas_api_notice('ADD_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id));
}
if (!preg_match('/^[\d +]*$/', $phone)){
if (!WC_Validation::is_phone($phone)){
return wiaas_api_notice('INVALID_PHONE_NUMBER', 'error', Wiaas_Customer::get_customer_info($customer_id));
};