Esempio n. 1
0
 /**
  * Add one or more constraints to a field.
  *
  * @param string $field
  * @param AbstractConstraint|AbstractConstraint[] $constraint
  *
  * @throws MismatchedArgumentTypesException
  * @return $this
  */
 public function let($field, $constraint)
 {
     Arguments::define(Boa::string(), Boa::either(Boa::instance(AbstractConstraint::class), Boa::arrOf(Boa::instance(AbstractConstraint::class))))->check($field, $constraint);
     if (!$this->constraints->member($field)) {
         $this->constraints = $this->constraints->insert($field, ArrayList::zero());
     }
     if (!is_array($constraint)) {
         $constraint = [$constraint];
     }
     $this->constraints = $this->constraints->insert($field, Maybe::fromMaybe(ArrayList::zero(), $this->constraints->lookup($field))->append(ArrayList::of($constraint)));
     return $this;
 }
Esempio n. 2
0
 /**
  * Get all the annotations for a single field.
  *
  * @param string $fieldName
  *
  * @return Maybe
  */
 public function getFieldAnnotations($fieldName)
 {
     return $this->annotations->lookup($fieldName);
 }