MailPoet\EmailEditor\Engine

Send_Preview_Email::validate_data()privateWC 1.0

Validates the provided data array.

Method of the class: Send_Preview_Email{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->validate_data( $data );
$data(array) (required)
The data array to be validated.

Send_Preview_Email::validate_data() code WC 9.8.1

private function validate_data( array $data ) {
	if ( empty( $data['email'] ) || empty( $data['postId'] ) ) {
		throw new \InvalidArgumentException( esc_html__( 'Missing required data', 'woocommerce' ) );
	}

	if ( ! is_email( $data['email'] ) ) {
		throw new \InvalidArgumentException( esc_html__( 'Invalid email', 'woocommerce' ) );
	}
}