you can do it with Function post_type_exists
https://codex.wordpress.org/Function_Reference/post_type_exists
Examples
if ( post_type_exists( 'book' ) ) {
echo 'the Book post type exists';
}
$exists = post_type_exists( 'post' );
// returns true
$exists = post_type_exists( 'page' );
// returns true
$exists = post_type_exists( 'book' );
// returns true if book is a registered post type
$exists = post_type_exists( 'xyz' );
// returns false if xyz is not a registered post type