I am validating csv files. I am thinking of using constraints and constraint validator framework available in Drupal to validate the data in the files. However, these seem to be designed to be attached to entity fields. For example.
/** Implements hook_entity_base_field_info_alter(). */ function projectname_commerce_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) { if ($entity_type->id() === 'commerce_order_item') { if (!empty($fields['unit_price'])) { $fields['unit_price']->addConstraint('PriceBelowMax'); } } } where PriceBelowmax is a custom constraint. I would like to attach this constraint to a custom data array. For example
myCustomValidatemethod($data_array, $constraints) where constraints would be the list of constraints defined in Drupal both core and custom. Is there some reference for the above method.