Validate nonce with post ID in AJAX

I’m trying to create a nonce in an AJAX form where I can pass in a post ID. Then, validate it of course.

I want to confirm that if the action is intended, but also the post ID so someone cannot just change the POST ID input field value and take control of another post.

Here’s the nonce on the front end:

wp_create_nonce('my_edit_post' . $  post_id); 

And backend action:

add_action('wp_ajax_my_edit_post', 'handle_edit_post_form'); add_action('wp_ajax_nopriv_my_edit_post', 'handle_edit_post_form');  function handle_edit_post_form(){    if( ! isset( $  _POST['edit-post-nonce'] ) || ! wp_verify_nonce( $  _POST['edit-post-nonce'], 'my_edit_post')){      //failed   }   else {      //validated   } 

The whole thing doesn’t work because the $ post_id is not in the backend action.

But how can I pass it in there? $ post_id is undefined in the backend action.

The post ID is going to be dynamic (and not the referer URL’s ID).