I have a link field for a content type. I am implementing a validation where users cannot enter a domain name in the field if it has been used already. For that purpose, I need a direct way to derive domain from the field value (full url) for comparison with the domain name of the url entered.
$result = \Drupal::entityQuery('node') ->condition('type', 'ABC') ->condition('field_1', parse_url($url_entered)['host']->execute();
The problem is field_1 is a full url where as I only want validation over the domain name.
Is it possible to do using Entity Query? If not, any suggestions?