public function DateIntervalData::getConstraints in Duration Field 8.2
Same name and namespace in other branches
- 3.0.x src/Plugin/DataType/DateIntervalData.php \Drupal\duration_field\Plugin\DataType\DateIntervalData::getConstraints()
Gets a list of validation constraints.
Return value
array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.
Overrides TypedData::getConstraints
File
- src/
Plugin/ DataType/ DateIntervalData.php, line 51
Class
- DateIntervalData
- Provides the Date Interval data type.
Namespace
Drupal\duration_field\Plugin\DataTypeCode
public function getConstraints() {
$constraint_manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$constraints = parent::getConstraints();
// Add a constraint to ensure that submitted data is valid for a PHP
// DateInterval object.
$constraints[] = $constraint_manager
->create('php_date_interval', []);
return $constraints;
}