Validates the Pattern constraint of '<em>Hex Color</em>'.
<!-- begin-user-doc -->
<!-- end-user-doc -->
@generated
487087
public boolean validateHexColor_Pattern(String hexColor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validatePattern(ColorPackage.Literals.HEX_COLOR, hexColor, HEX_COLOR__PATTERN__VALUES, diagnostics, context);
	}
13178
@Override
	public boolean validate(Graph<K, VV, EV> graph) throws Exception {
		DataSet<Tuple1<K>> edgeIds = graph.getEdges()
				.flatMap(new MapEdgeIds<>()).distinct();
		DataSet<K> invalidIds = graph.getVertices().coGroup(edgeIds).where(0)
				.equalTo(0).with(new GroupInvalidIds<>()).first(1);

		return invalidIds.map(new KToTupleMap<>()).count() == 0;
	}
687564
function verify(node, pattern, flags) {
            const patternNode = parser.parsePattern(
                pattern,
                0,
                pattern.length,
                flags.includes("u")
            );
            const has = {
                surrogatePairWithoutUFlag: false,
                combiningClass: false,
                variationSelector: false,
                emojiModifier: false,
                regionalIndicatorSymbol: false,
                zwj: false
            };

            visitRegExpAST(patternNode, {
                onCharacterClassEnter(ccNode) {
                    for (const chars of iterateCharacterSequence(ccNode.elements)) {
                        for (const kind of kinds) {
                            has[kind] = has[kind] || hasCharacterSequence[kind](chars);
                        }
                    }
                }
            });

            for (const kind of kinds) {
                if (has[kind]) {
                    context.report({ node, messageId: kind });
                }
            }
        }
1257631
def _validate(self, writing=False):
        """"""
        if self.colorspace is not None and self.icc_profile is not None:
            msg = ("Colorspace and icc_profile cannot both be set when "
                   "creating a ColourSpecificationBox.")
            self._dispatch_validation_error(msg, writing=writing)

        if self.method not in _COLORSPACE_METHODS.keys():
            msg = "Invalid colorspace method value ({method})."
            msg = msg.format(method=self.method)
            if writing:
                raise IOError(msg)
            else:
                warnings.warn(msg, UserWarning)

        if self.approximation not in _APPROXIMATION_MEASURES.keys():
            msg = "Invalid colr approximation value ({approx})."
            msg = msg.format(approx=self.approximation)
            if not writing:
                # Don't bother to check this for the case of writing=True
                # because it's already handles in the wrapping code.
                warnings.warn(msg, UserWarning)
535360
public static void requireValid(@NotNull final Validator validator, @NotNull final Object value, @Nullable final Class<?>... groups)
            throws ConstraintViolationException {
        // CHECKSTYLE:ON

        final Set<ConstraintViolation<Object>> constraintViolations = validator.validate(value);
        if (constraintViolations.size() > 0) {
            final StringBuffer sb = new StringBuffer();
            for (final ConstraintViolation<Object> constraintViolation : constraintViolations) {
                if (sb.length() > 0) {
                    sb.append(", ");
                }
                sb.append("[" + constraintViolation.getPropertyPath() + "] " + constraintViolation.getMessage() + " {"
                        + constraintViolation.getInvalidValue() + "}");
            }
            throw new ConstraintViolationException(sb.toString(), constraintViolations);
        }

    }
1119781
public static String shorthandHex(String color) {
		validateHex(color);
		if (color.length() > 5) {
			StringBuilder shorthandColor = new StringBuilder();
			int startIndex = 0;
			if (color.startsWith("#")) {
				shorthandColor.append("#");
				startIndex++;
			}
			for (; startIndex < color.length(); startIndex += 2) {
				String shorthand = shorthandHexSingle(color.substring(
						startIndex, startIndex + 2));
				if (shorthand.length() > 1) {
					shorthandColor = null;
					break;
				}
				shorthandColor.append(shorthand);
			}
			if (shorthandColor != null) {
				color = shorthandColor.toString();
			}
		}

		return color;
	}
690079
private static void check(Set<ConstraintViolation<Object>> constraintViolations) {
        Iterator<ConstraintViolation<Object>> iterator = constraintViolations.iterator();
        if (iterator.hasNext()) {
            throw new ValidationException(iterator.next().getMessage());
        }
    }
683936
public static void validateNodeAndPatterns(final Node node, final Pattern... patterns)
            throws IllegalArgumentException
   {
      // Precondition checks
      if (node == null)
      {
         throw new IllegalArgumentException("node must be specified");
      }
      if (patterns == null || patterns.length == 0)
      {
         throw new IllegalArgumentException("At least one pattern must be specified");
      }

      // OK
   }
599805
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    if (pvalue == null) {
      return true;
    }
    try {
      String countryCode =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, fieldCountryCode);
      final String postalCode =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, fieldPostalCode);
      if (StringUtils.isEmpty(postalCode)) {
        return true;
      }

      if (allowLowerCaseCountryCode) {
        countryCode = StringUtils.upperCase(countryCode);
      }

      final String regExCheck = POSTAL_CODE_MAP.postalCodes().get(countryCode);
      if (regExCheck == null) {
        return true;
      }
      if (postalCode.matches(regExCheck)) {
        return true;
      }
      switchContext(pcontext);
      return false;
    } catch (final Exception ignore) {
      switchContext(pcontext);
      return false;
    }
  }
619820
@SuppressWarnings("unchecked")
    private BaseDescr lhsPatternBind(PatternContainerDescrBuilder<?, ?> ce,
            final boolean allowOr) throws RecognitionException {
        PatternDescrBuilder<?> pattern = null;
        CEDescrBuilder<?, OrDescr> or = null;
        BaseDescr result = null;

        Token first = input.LT(1);
        pattern = helper.start((DescrBuilder<?, ?>) ce,
                PatternDescrBuilder.class,
                null);
        if (pattern != null) {
            result = pattern.getDescr();
        }

        String label = null;
        boolean isUnification = false;
        if (input.LA(1) == DRL6Lexer.ID && input.LA(2) == DRL6Lexer.COLON && !helper.validateCEKeyword(1)) {
            label = label(DroolsEditorType.IDENTIFIER_PATTERN);
            if (state.failed)
                return null;
        } else if (input.LA(1) == DRL6Lexer.ID && input.LA(2) == DRL6Lexer.UNIFY && !helper.validateCEKeyword(1)) {
            label = unif(DroolsEditorType.IDENTIFIER_PATTERN);
            if (state.failed)
                return null;
            isUnification = true;
        }

        if (input.LA(1) == DRL6Lexer.LEFT_PAREN) {
            try {
                match(input,
                        DRL6Lexer.LEFT_PAREN,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
                    return null;

                if (helper.validateCEKeyword(1)) {
                    failMismatchedTokenException();
                    return null; // in case it is backtracking
                }

                lhsPattern(pattern,
                        label,
                        isUnification);
                if (state.failed)
                    return null;

                if (allowOr && helper.validateIdentifierKey(DroolsSoftKeywords.OR) && ce instanceof CEDescrBuilder) {
                    if (state.backtracking == 0) {
                        // this is necessary because of the crappy bind with multi-pattern OR syntax
                        or = ((CEDescrBuilder<DescrBuilder<?, ?>, OrDescr>) ce).or();
                        result = or.getDescr();

                        helper.end(PatternDescrBuilder.class,
                                pattern);
                        helper.start(or,
                                CEDescrBuilder.class,
                                null);
                        // adjust real or starting token:
                        helper.setStart(or,
                                first);

                        // remove original pattern from the parent CE child list:
                        ((ConditionalElementDescr) ce.getDescr()).getDescrs().remove(pattern.getDescr());
                        // add pattern to the OR instead
                        or.getDescr().addDescr(pattern.getDescr());
                    }

                    while (helper.validateIdentifierKey(DroolsSoftKeywords.OR)) {
                        match(input,
                                DRL6Lexer.ID,
                                DroolsSoftKeywords.OR,
                                null,
                                DroolsEditorType.KEYWORD);
                        if (state.failed)
                            return null;

                        pattern = helper.start(or,
                                PatternDescrBuilder.class,
                                null);
                        // new pattern, same binding
                        lhsPattern(pattern,
                                label,
                                isUnification);
                        if (state.failed)
                            return null;

                        helper.end(PatternDescrBuilder.class,
                                pattern);
                    }
                }

                match(input,
                        DRL6Lexer.RIGHT_PAREN,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
                    return null;

            } finally {
                if (or != null) {
                    helper.end(CEDescrBuilder.class,
                            or);
                } else {
                    helper.end(PatternDescrBuilder.class,
                            pattern);
                }
            }

        } else {
            try {
                lhsPattern(pattern,
                        label,
                        isUnification);
                if (state.failed)
                    return null;

            } finally {
                helper.end(PatternDescrBuilder.class,
                        pattern);
            }
        }

        return result;
    }
1101289
@Override
	public boolean validate(Object value) {
		if(constraints == null) {
			return false;
		}

		IConstraintChecker checker;
		for(BeanProperty constraint : constraints) {
			checker = checkers.get(constraint.getPropertyName());
			if(checker == null) {
				throw new RuntimeException("No checker found for constraint "
						+ "'" + constraint.getPropertyName() + "'"
				);
			}
			checker.check(value, constraint);
		}
		return true;
	}
713006
private static void checkPattern(String s) throws ProblemException {
        // Package names like foo.bar.gamma are allowed, and
        // package names suffixed with .* like foo.bar.* are
        // also allowed.
        Pattern p = Pattern.compile("[a-zA-Z_]{1}[a-zA-Z0-9_]*(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*(\\.\\*)?+");
        Matcher m = p.matcher(s);
        if (!m.matches()) {
            throw new ProblemException("The string \""+s+"\" is not a proper package name pattern.");
        }
    }
634735
def _write_validate(self):
        """"""
        if self.colorspace is None:
            msg = ("Writing colr boxes without enumerated "
                   "colorspaces is not supported at this time.")
            self._dispatch_validation_error(msg, writing=True)

        if self.icc_profile is None:
            if self.colorspace not in [SRGB, GREYSCALE, YCC]:
                msg = ("Colorspace should correspond to one of SRGB, "
                       "GREYSCALE, or YCC.")
                self._dispatch_validation_error(msg, writing=True)

        self._validate(writing=True)
47271
function ( color, errorMsg ) {
            if ( this.REG_RGB.test(color) || this.REG_HSL.test(color) ) {
                var typeName = color.match( /([a-z]+)\(/ );
                return this.TYPES[typeName[1].toUpperCase()];
            } else if ( this.REG_HEX.test(color) || this.REG_HEX3.test(color) ) {
                return this.TYPES.HEX;
            } else if ( typeof color === 'string' && this.KEYWORDS[color.toLowerCase()] ) {
                return 'keyword'
            } else {
                if ( errorMsg ) warning( errorMsg );
                return undefined;
            }
        }
525978
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    String valueAsString = Objects.toString(pvalue, StringUtils.EMPTY);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (ignoreWhiteSpaces) {
      valueAsString = valueAsString.replaceAll("\\s", StringUtils.EMPTY);
    }
    if (ignoreMinus) {
      valueAsString = valueAsString.replaceAll("-", StringUtils.EMPTY);
    }
    if (ignoreSlashes) {
      valueAsString = valueAsString.replaceAll("/", StringUtils.EMPTY);
    }
    return StringUtils.length(valueAsString) == size1 || StringUtils.length(valueAsString) == size2;
  }
601622
function validateFormatColor(obj) {
	return COLORS.indexOf(obj) !== -1 || obj.match(colorsReHex3) || obj.match(colorsReHex6)
		|| obj.match(colorsReRgbNum) || obj.match(colorsReRgbPerc);
}
386530
@Override
  public final boolean isValid(final String pvalue, final ConstraintValidatorContext pcontext) {
    if (StringUtils.isEmpty(pvalue)) {
      return true;
    }
    return charsetEncoder.canEncode(pvalue);
  }