Automattic\WooCommerce\Internal\StockNotifications

Notification::validate_propsprotectedWC 1.0

Validate the data.

Method of the class: Notification{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_props();

Notification::validate_props() code WC 10.3.6

protected function validate_props() {
	if ( empty( $this->get_prop( 'product_id' ) ) ) {
		$this->error( 'stock_notification_product_id_required', __( 'Product ID is required.', 'woocommerce' ) );
	}

	if ( empty( $this->get_prop( 'user_id' ) ) && empty( $this->get_prop( 'user_email' ) ) ) {
		$this->error( 'stock_notification_user_id_or_user_email_required', __( 'User ID or User Email is required.', 'woocommerce' ) );
	}

	if ( ! empty( $this->get_prop( 'user_email' ) ) && ! filter_var( $this->get_prop( 'user_email' ), FILTER_VALIDATE_EMAIL ) ) {
		$this->error( 'stock_notification_user_email_invalid', __( 'User Email is invalid.', 'woocommerce' ) );
	}
}