Add custom validation for phone number

This commit is contained in:
emilicastells 2022-06-17 16:04:57 +02:00
parent 0262549382
commit b362f295f8
No known key found for this signature in database
GPG key ID: 1520C07081754570

View file

@ -345,6 +345,11 @@ class PayUponInvoice {
if ( $birth_date && ! $this->pui_helper->validate_birth_date( $birth_date ) ) {
$errors->add( 'validation', __( 'Invalid birth date.', 'woocommerce-paypal-payments' ) );
}
$national_number = filter_input( INPUT_POST, 'billing_phone', FILTER_SANITIZE_STRING );
if ( ! preg_match( '/^[0-9]{1,14}?$/', $national_number ) ) {
$errors->add( 'validation', __( 'Phone number size must be between 1 and 14', 'woocommerce-paypal-payments' ) );
}
},
10,
2