Using arguments in addConstraint() for validation I implemented hook_entity_bundle_field_info_alter() to add validation to fields of a node type. I got $bundle as an argument in the hook and I need to pass it in $options argument like below:

$fields['field_tags']-&gt;addConstraint('NodeValidate', $bundle);


How can I access this argument in NodeValidateConstraintValidator? Am I passing the argument correctly?

$options provided in addConstraint can be accessed in the constructor using parent::__construct($options) in __construct() function build the options.

hook_entity_base_field_info_alter() doesn't contain a $bundle argument, as it is defined as function hook_entity_base_field_info_alter(&amp;$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type). How can I validate the base field for a particular node type?
Options needs to be an array I think. You can access it on the constraint object in your validator, see ListStringItem::propertyDefinitions() and LengthValidator, which then uses it as $constraint->max.
Base fields are exactly that. Base fields. There is no bundle, they are the same for all bundles of an entity type (they can be overriden per-bundle, but then they become accessible in the bundle hook).
You shouldn't ask two different questions together :)