org.qi4j.api.constraint

## Interface Constraint<ANNOTATION extends Annotation,TYPE>

- All Superinterfaces:
    Serializable
  All Known Implementing Classes:
    AlarmNameFormat.AlarmNameConstraint, ContainsConstraint, CronExpressionConstraint, GreaterThanConstraint, InstanceOfConstraint, LessThanConstraint, MatchesConstraint, MaxLengthConstraint, MinLengthConstraint, NotEmptyCollectionConstraint, NotEmptyStringConstraint, OneOfConstraint, RangeConstraint, Requires.RequiresRoleConstraint, RequiresValid.RequiresValidConstraint, URIConstraint, URLConstraint

      public interface Constraint<ANNOTATION extends Annotation,TYPE>
      extends Serializable

  All Constraints must implement this interface, which is used for each value validation.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isValid(ANNOTATION annotation, TYPE value)` For each value or parameter which should be checked this method will be invoked.

- - ### Method Detail

    - #### isValid

          boolean isValid(ANNOTATION annotation,
                        TYPE value)

      For each value or parameter which should be checked this method will be invoked. If the method returns true the value is valid. If it returns false the value is considered invalid. When all constraints have been checked a ConstraintViolationException will be thrown with all the constraint violations that were found.
      Parameters:
        `annotation` - the annotation to match
        `value` - the value to be checked
      Returns:
        true if valid, false if invalid