Can you make a field unique in a content type?
You can add a validation constraint to your field.
There is two ways to do that:


Setting a validation constraint to a field you haven't defined by implementing hook_entity_bundle_field_info_alter:


function YOURMODULE_entity_bundle_field_info_alter(&amp;$fields, EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type-&gt;id() === 'ENTITY_TYPE' &amp;&amp; $bundle === 'BUNDLE_NAME') {
    if (isset($fields['FIELD_NAME'])) {
      $fields['FIELD_NAME']-&gt;addConstraint('UniqueField');
    }
  }
}



Setting a validation constraint to a field you have defined in baseFieldDefinitions


public static function baseFieldDefinitions(EntityTypeInterface $entityType) {
 $fields['FIELD_NAME'] = BaseFieldDefinition::create('string')
   -&gt;setLabel(t('MY UNIQUE FIELD'))
   -&gt;addConstraint('UniqueField');

 return $fields;
}



If you want to create your own validation constraint you can check here.