diff --git a/omnisend/includes/SDK/V1/class-event.php b/omnisend/includes/SDK/V1/class-event.php index c324463..18202b7 100644 --- a/omnisend/includes/SDK/V1/class-event.php +++ b/omnisend/includes/SDK/V1/class-event.php @@ -1,4 +1,5 @@ merge_from( $contact->validate() ); + if ( $this->contact instanceof Contact ) { + $error->merge_from( $this->contact->validate() ); } - if ( $this->$event_name == null ) { + if ( $this->event_name == null ) { $error->add( 'event_name', 'Is required.' ); } - if ( $this->$event_name != null && ! is_string( $this->$event_name ) ) { - $error->add( $event_name, 'Not a string.' ); + if ( $this->event_name != null && ! is_string( $this->event_name ) ) { + $error->add( 'event_name', 'Not a string.' ); } - if ( $this->$event_version != null && ! is_string( $this->$event_version ) ) { - $error->add( $event_version, 'Not a string.' ); + if ( $this->event_version != null && ! is_string( $this->event_version ) ) { + $error->add( 'event_version', 'Not a string.' ); } - if ( $this->$origin != null && ! is_string( $this->$origin ) ) { - $error->add( $origin, 'Not a string.' ); + if ( $this->origin != null && ! is_string( $this->origin ) ) { + $error->add( 'origin', 'Not a string.' ); } - if ( $this->$event_time != null ) { - $dt = DateTime::createFromFormat( 'Y-m-d', $event_time ); + if ( $this->event_time != null ) { + $dt = DateTime::createFromFormat( 'Y-m-d', $this->event_time ); if ( ! $dt ) { - $error->add( $event_time, 'Not valid date format.' ); + $error->add( 'event_time', 'Not valid date format.' ); } } - foreach ( $properties as $name => $value ) { + foreach ( $this->properties as $name => $value ) { if ( ! is_string( $name ) ) { $error->add( $name, 'Not a string.' ); }