WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

BillingAddressSchema::validate_callback() public WC 1.0

Validate the given address object.

{} It's a 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.

Code of BillingAddressSchema::validate_callback() WC 5.6.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' )
		);
	}

	if ( ! empty( $address['phone'] ) && ! \WC_Validation::is_phone( $address['phone'] ) ) {
		$errors->add(
			'invalid_phone',
			__( 'The provided phone number is not valid', 'woocommerce' )
		);
	}

	return $errors->has_errors( $errors ) ? $errors : true;
}