function ConstraintManager::create
Creates a validation constraint.
Parameters
string $name: The name or plugin id of the constraint.
mixed $options: The options to pass to the constraint class. Required and supported options depend on the constraint class.
Return value
\Symfony\Component\Validator\Constraint A validation constraint plugin.
File
- 
              core/lib/ Drupal/ Core/ Validation/ ConstraintManager.php, line 79 
Class
- ConstraintManager
- Constraint plugin manager.
Namespace
Drupal\Core\ValidationCode
public function create($name, $options) {
  if (!is_array($options)) {
    // Plugins need an array as configuration, so make sure we have one.
    // The constraint classes support passing the options as part of the
    // 'value' key also.
    $options = isset($options) ? [
      'value' => $options,
    ] : [];
  }
  return $this->createInstance($name, $options);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
