WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Admin\API

OnboardingProfile::rest_validate_marketing_email() public WC 1.0

Optionally validates email if user agreed to marketing or if email is not empty.

{} It's a method of the class: OnboardingProfile{}

No Hooks.

Return

true|WP_Error.

Usage

$result = OnboardingProfile::rest_validate_marketing_email( $value, $request, $param );
$value(mixed) (required)
Email value.
$request(WP_REST_Request) (required)
Request object.
$param(string) (required)
Parameter name.

Code of OnboardingProfile::rest_validate_marketing_email() WC 6.1.1

public static function rest_validate_marketing_email( $value, $request, $param ) {
	$is_agree_marketing = $request->get_param( 'is_agree_marketing' );
	if (
		( $is_agree_marketing || ! empty( $value ) ) &&
		! is_email( $value ) ) {
		return new \WP_Error( 'rest_invalid_email', __( 'Invalid email address', 'woocommerce' ) );
	};
	return true;
}