Adding Constraint to Paragraph field
Yes, use hook_entity_bundle_field_info_alter and when you add a constraint to the field (and not to a item or property), your constraint gets the entire field item list, so you can check how many items you have of which type, see FieldConfigInterface::addConstraint:

function mymodule_entity_bundle_field_info_alter(&amp;$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type-&gt;id() == 'node' &amp;&amp; $bundle == 'page') {
    $fields['field_paragraph']-&gt;addConstraint('MymoduleParagraphTypes');
  }
}


Example for a constraint restricting the field to four paragraph items of a specific type:

  public function validate($items, Constraint $constraint) {
    $paragraphs = array_filter($items-&gt;referencedEntities(), function ($paragraph) {
      return $paragraph-&gt;bundle() === 'image';
    });
    if (!empty($paragraphs) &amp;&amp; count($paragraphs) != 4) {
      $this-&gt;context-&gt;addViolation($constraint-&gt;errorMessage);
    }
  }


You can generate the constraint with the Drush command:

drush generate plugin-constraint