How to use modified (calculated) value of a field in Drupal entity query condition? 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')
-&gt;condition('type', 'ABC')
-&gt;condition('field_1', parse_url($url_entered)['host']-&gt;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?
To do so you can use LIKE operator in your query like the following:
$host = parse_url($url_entered)['host'];
$result = \Drupal::entityQuery('node')
  -&gt;condition('type', 'ABC')
  -&gt;condition('field_link', &quot;%&quot; . $host . &quot;%&quot;, 'LIKE')-&gt;execute();

UPDATE
if you want to check that the exact host exist, you should select all values of your field and then compare with the entered host.
$host = parse_url($url_entered)['host'];
// Select all uris of field link.
$database = \Drupal::database();
$query = $database-&gt;select('node__field_link', 'nfl')
  -&gt;condition('nfl.bundle', 'page')
  -&gt;fields('nfl', ['field_link_uri']);
$result = $query-&gt;execute()-&gt;fetchAll(PDO::FETCH_COLUMN, 0);
$hosts = [];
// extract all hosts.
foreach ($result as $item){
  $hosts[] = parse_url($item)['host'];
}
// Check if the host already exist.
if (in_array($host, $hosts)){
  // Do what you want ici !
}