Remove required from a custom field created from WooCommerce Checkout Field Editor plugin

I found a solution to the problem.

This code remove the validation of the custom fields if the Local Pickup method is selected.

add_action('woocommerce_after_checkout_validation', 'thwcfe_remove_unwanted_error', 11, 2);
function thwcfe_remove_unwanted_error($data, $errors){
    if (isset($data['shipping_method']) && $data['shipping_method'][0] == ' local_pickup:8') {
        $errors->remove(' billing_region');
        $errors->remove(' billing_cityalt');
    }
}