Automattic\WooCommerce\StoreApi\Schemas\V1
BillingAddressSchema::validate_callback()
Validate the given address object.
Method of the class: BillingAddressSchema{}
No Hooks.
Return
true|\WP_Error
.
Usage
$BillingAddressSchema = new BillingAddressSchema(); $BillingAddressSchema->validate_callback( $address, $request, $param );
- $address(array) (required)
- Value being sanitized.
- $request(\WP_REST_Request) (required)
- The Request.
- $param(string) (required)
- The param being sanitized.
BillingAddressSchema::validate_callback() BillingAddressSchema::validate callback code WC 7.7.0
public function validate_callback( $address, $request, $param ) { $errors = parent::validate_callback( $address, $request, $param ); $address = $this->sanitize_callback( $address, $request, $param ); $errors = is_wp_error( $errors ) ? $errors : new \WP_Error(); if ( ! empty( $address['email'] ) && ! is_email( $address['email'] ) ) { $errors->add( 'invalid_email', __( 'The provided email address is not valid', 'woocommerce' ) ); } return $errors->has_errors( $errors ) ? $errors : true; }