make a Constraint which will try to check and collect errors
185765
public static <T> Constraint
            checking(Function<String, T> check, String messageOrKey, boolean isKey, String... extraMessageArgs) {
        return mkSimpleConstraint(((label, vString, messages) -> {
            logger.debug("checking for {}", vString);

            if (isEmptyStr(vString)) return null;
            else {
                try {
                    check.apply(vString);
                    return null;
                } catch (Exception ex) {
                    String msgTemplate = isKey ? messages.get(messageOrKey) : messageOrKey;
                    List<String> messageArgs = appendList(Arrays.asList(vString), extraMessageArgs);
                    return String.format(msgTemplate, messageArgs.toArray());
                }
            }
        }), null);
    }
469644
def check(definition, data, *args, **kwargs):
    """"""
    checker = checker_factory(definition)
    return checker(data, *args, **kwargs)
818996
private void sanityCheck(
      String seriesName,
      List<?> xData,
      List<? extends Number> yData,
      List<? extends Number> errorBars) {

    if (seriesMap.keySet().contains(seriesName)) {
      throw new IllegalArgumentException(
          "Series name >"
              + seriesName
              + "< has already been used. Use unique names for each series!!!");
    }
    if (yData == null) {
      throw new IllegalArgumentException("Y-Axis data cannot be null!!!");
    }
    if (yData.size() == 0) {
      throw new IllegalArgumentException("Y-Axis data cannot be empty!!!");
    }
    if (xData != null && xData.size() == 0) {
      throw new IllegalArgumentException("X-Axis data cannot be empty!!!");
    }
    if (errorBars != null && errorBars.size() != yData.size()) {
      throw new IllegalArgumentException("Error bars and Y-Axis sizes are not the same!!!");
    }
  }
777838
void checkCheckConstraint(Session session, Table table, Object[] data) {

/*
        if (session.compiledStatementExecutor.rangeIterators[1] == null) {
            session.compiledStatementExecutor.rangeIterators[1] =
                rangeVariable.getIterator(session);
        }
*/
        RangeIteratorBase it =
            (RangeIteratorBase) session.sessionContext.getCheckIterator();

        if (it == null) {
            it = rangeVariable.getIterator(session);

            session.sessionContext.setCheckIterator(it);
        }

        it.currentData = data;

        boolean nomatch = Boolean.FALSE.equals(check.getValue(session));

        it.currentData = null;

        if (nomatch) {
            String[] info = new String[] {
                name.name, table.tableName.name
            };

            throw Error.error(ErrorCode.X_23504, ErrorCode.CONSTRAINT, info);
        }
    }
501878
function setConstraint(sKey, vValue) {
			if (vValue !== undefined) {
				mConstraints = mConstraints || {};
				mConstraints[sKey] = vValue;
			}
		}
1325654
private boolean checkConstraint(Collection<String> constraints, Tile tile)
    {
        return tile != null
               && constraints.contains(mapGroup.getGroup(tile))
               && !tile.getFeature(TileCollision.class).getCollisionFormulas().isEmpty();
    }
363826
function () {
			var args = slice.call(arguments),
				constraint = options.args_map.getOrPut(args, function() {
					return new Constraint(function () {
						return getter_fn.apply(options.context, args);
					});
				});
			return constraint.get();
		}
1199666
public boolean isConstraintError(SQLException e) {
        if (e != null) {
            String sqlstate = e.getSQLState();
            if (sqlstate != null) {
                return sqlstate.startsWith(SQLSTATE_CONSTRAINT_VIOLATION_CLASS_CODE);
            }
        }
        return false;
    }
500470
public Set<ConstraintViolation> validate() {
		Set<ConstraintViolation> errors = new LinkedHashSet<ConstraintViolation>();
		for (int record = 1; record <= 3; ++record) {
			errors.addAll(validate(record));
		}
		return errors;
	}
154441
def validate(self, instance):
        """"""
        errors = {}
        self._validate_instance(instance, errors)

        if len(errors) > 0:
            raise ValidationException(errors)
628647
def filter_errors(errors, select=None, ignore=None, **params):
    
    select = select or []
    ignore = ignore or []

    for e in errors:
        for s in select:
            if e.number.startswith(s):
                yield e
                break
        else:
            for s in ignore:
                if e.number.startswith(s):
                    break
            else:
                yield e
1103270
def make_syntax_err(self, err, original):
        """"""
        msg, loc = err.args
        return self.make_err(CoconutSyntaxError, msg, original, loc)
1258346
def validate(self, value):
        
        errors = []

        # Make sure the type validates first.
        valid = self._is_valid(value)
        if not valid:
            errors.append(self.fail(value))
            return errors

        # Then validate all the constraints second.
        for constraint in self._constraints_inst:
            error = constraint.is_valid(value)
            if error:
                errors.append(error)

        return errors
153451
function validateInclusion(attr, conf, err) {
    if (nullCheck.call(this, attr, conf, err)) return;

    if (!~conf.in.indexOf(this[attr])) {
        err();
    }
}
1351602
private static <E> Collection<E> checkElements(
      Collection<E> elements, Constraint<? super E> constraint) {
    Collection<E> copy = Lists.newArrayList(elements);
    for (E element : copy) {
      constraint.checkElement(element);
    }
    return copy;
  }
342238
private boolean checkValueConstraints(int requiredType, String[] constraints, Value value)
   {
      ValueConstraintsMatcher constrMatcher =
         new ValueConstraintsMatcher(constraints, locationFactory, dataManager, nodeTypeDataManager);

      try
      {
         return constrMatcher.match(((BaseValue)value).getInternalData(), requiredType);
      }
      catch (RepositoryException e1)
      {
         return false;
      }
   }
579069
def _check_satisfy_constraints(self, label, xmin, ymin, xmax, ymax, width, height):
        """"""
        if (xmax - xmin) * (ymax - ymin) < 2:
            return False  # only 1 pixel
        x1 = float(xmin) / width
        y1 = float(ymin) / height
        x2 = float(xmax) / width
        y2 = float(ymax) / height
        object_areas = self._calculate_areas(label[:, 1:])
        valid_objects = np.where(object_areas * width * height > 2)[0]
        if valid_objects.size < 1:
            return False
        intersects = self._intersect(label[valid_objects, 1:], x1, y1, x2, y2)
        coverages = self._calculate_areas(intersects) / object_areas[valid_objects]
        coverages = coverages[np.where(coverages > 0)[0]]
        return coverages.size > 0 and np.amin(coverages) > self.min_object_covered