/*
(non-Javadoc)

@see javax.validation.ConstraintValidator#isValid(java.lang.Object,
javax.validation.ConstraintValidatorContext)
345644
@Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        //may contain multiple values, semicolon separated.
        if (!StringUtils.isBlank(value)) {
            String[] values = value.split(";");
            for (String val : values) {
                try {
                    new IpAddressMatcher(val);
                } catch (IllegalArgumentException ex) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }
    }
171383
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString;
    if (ignoreWhitspaces) {
      valueAsString =
          Objects.toString(pvalue, StringUtils.EMPTY).replaceAll("\\s+", StringUtils.EMPTY);
    } else {
      valueAsString = Objects.toString(pvalue, null);
    }
    if (StringUtils.isEmpty(valueAsString)) {
      // empty field is ok
      return true;
    }
    if (valueAsString.length() != BIC_LENGTH_MIN && valueAsString.length() != BIC_LENGTH_MAX) {
      // to short or to long, but it's handled by size validator!
      return true;
    }
    if (!valueAsString.matches(BIC_REGEX)) {
      // format is wrong!
      return false;
    }
    final String countryCode = valueAsString.substring(4, 6);
    final IbanLengthDefinition validBicLength = IBAN_LENGTH_MAP.ibanLengths().get(countryCode);

    return validBicLength != null;
  }
1188863
@Override
    public ValidationResult validate(PMContext ctx) {
        final ValidationResult res = new ValidationResult();
        final Object fieldvalue = ctx.getFieldValue();
        res.setSuccessful(fieldvalue != null);
        if (!res.isSuccessful()) {
            res.getMessages().add(MessageFactory.error(
                    ctx.getEntity(), ctx.getField(),
                    get("msg", "pm.validator.not.null"),
                    ctx.getField().getId()));
        }
        return res;
    }
829067
public <A extends Annotation, V> ConstraintValidatorContextImpl<A, V> //
      createConstraintValidatorContext(final ConstraintDescriptor<A> descriptor) {
    return new ConstraintValidatorContextImpl<>(PathImpl.createCopy(this.path), descriptor);
  }
1270318
public boolean isValid(String value) {
        if (value == null) {
            return false;
        }
        for (Pattern pattern : patterns) {
            if (pattern.matcher(value).matches()) {
                return true;
            }
        }
        return false;
    }
639706
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    if (pvalue == null) {
      return true;
    }
    try {
      String valueCountry =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, this.fieldCountryCode);
      final String valueIban =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, this.fieldIban);
      final String valueBic =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, this.fieldBic);
      final String bicOfIban = IbanUtil.getBicOfIban(valueIban);

      if (StringUtils.isEmpty(valueIban) && StringUtils.isEmpty(valueBic)) {
        return true;
      } else if (StringUtils.isEmpty(valueIban)) {
        pcontext.disableDefaultConstraintViolation();
        pcontext.buildConstraintViolationWithTemplate(NOT_EMPTY_MESSAGE)
            .addPropertyNode(this.fieldIban).addConstraintViolation();
        return false;
      } else if (StringUtils.isEmpty(valueBic)) {
        pcontext.disableDefaultConstraintViolation();
        pcontext.buildConstraintViolationWithTemplate(NOT_EMPTY_MESSAGE)
            .addPropertyNode(this.fieldBic).addConstraintViolation();
        return false;
      } else if (StringUtils.length(valueIban) >= IbanValidator.IBAN_LENGTH_MIN
          && StringUtils.length(valueBic) >= BicValidator.BIC_LENGTH_MIN) {
        String countryIban = valueIban.replaceAll("\\s+", StringUtils.EMPTY).substring(0, 2);
        String countryBic = valueBic.replaceAll("\\s+", StringUtils.EMPTY).substring(4, 6);
        if (StringUtils.length(valueCountry) != 2) {
          // missing country selection, us country of iban
          valueCountry = countryIban;
        }

        if (this.allowLowerCaseCountryCode) {
          valueCountry = StringUtils.upperCase(valueCountry);
          countryIban = StringUtils.upperCase(countryIban);
          countryBic = StringUtils.upperCase(countryIban);
        }

        boolean ibanCodeMatches = false;
        boolean bicCodeMatches = false;
        final boolean bicIbanMatches = bicOfIban == null || StringUtils.equals(bicOfIban, valueBic);
        switch (valueCountry) {
          case "GF": // French Guyana
          case "GP": // Guadeloupe
          case "MQ": // Martinique
          case "RE": // Reunion
          case "PF": // French Polynesia
          case "TF": // French Southern Territories
          case "YT": // Mayotte
          case "NC": // New Caledonia
          case "BL": // Saint Barthelemy
          case "MF": // Saint Martin
          case "PM": // Saint Pierre et Miquelon
          case "WF": // Wallis and Futuna Islands
            // special solution for French oversea teritorials with french registry
            ibanCodeMatches = "FR".equals(countryIban);
            bicCodeMatches = "FR".equals(countryBic);
            break;
          case "JE": // Jersey
          case "GG": // Guernsey
            // they can use GB or FR registry, but iban and bic code must match
            ibanCodeMatches = ("GB".equals(countryIban) || "FR".equals(countryIban))
                && countryBic.equals(countryIban);
            bicCodeMatches = "GB".equals(countryBic) || "FR".equals(countryBic);
            break;
          default:
            ibanCodeMatches = valueCountry.equals(countryIban);
            bicCodeMatches = valueCountry.equals(countryBic);
            break;
        }
        if (ibanCodeMatches && bicCodeMatches && bicIbanMatches) {
          return true;
        }
        pcontext.disableDefaultConstraintViolation();
        if (!ibanCodeMatches) {
          pcontext.buildConstraintViolationWithTemplate(this.message)
              .addPropertyNode(this.fieldIban).addConstraintViolation();
        }
        if (!bicCodeMatches) {
          pcontext.buildConstraintViolationWithTemplate(this.message).addPropertyNode(this.fieldBic)
              .addConstraintViolation();
        }
        if (!bicIbanMatches) {
          pcontext.buildConstraintViolationWithTemplate(this.messageWrongBic)
              .addPropertyNode(this.fieldBic).addConstraintViolation();
        }
        return false;
      } else {
        // wrong format, should be handled by other validators
        return true;
      }
    } catch (final Exception ignore) {
      return false;
    }
  }
351226
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (valueAsString.length() != ISIN_LENGTH) {
      // ISIN size is wrong, but that's handled by size annotation
      return true;
    }
    // calculate and check checksum (ISIN)
    return CHECK_ISIN.isValid(valueAsString);
  }
609090
@Override
	public boolean isValid(String value, ConstraintValidatorContext constraintContext) {

		// Si l'objet est null : false
		if(value == null) return matchOnEmpty;

		// Si l'objet n'est pas une chaine : false
		if(!(value instanceof String)) return false;
		
		// On caste
		String stringValue = (String) value;

		// Si la chaîne est vide : false
		if(stringValue == null || stringValue.length() == 0) return matchOnEmpty;
		
		// On retourne le matching
		return pattern.matcher(stringValue).matches();
	}
1356739
public static boolean isValid(String kontonummer) {
        try {
            KontonummerValidator.getKontonummer(kontonummer);
            return true;
        } catch (IllegalArgumentException e) {
            return false;
        }
    }
694501
public boolean isValid() {
        boolean valid = true;
        for (PolygonMarkers polygon : polygonMarkers) {
            valid = polygon.isValid();
            if (!valid) {
                break;
            }
        }
        return valid;
    }
1050988
@Override
	public boolean isValid(String value, ConstraintValidatorContext constraintContext) {
		
		// Si l'objet est null : false
		if(value == null) return false;
		
		// Si l'objet n'est pas une chaine : false
		if(!(value instanceof String)) return false;
		
		// On caste
		String stringValue = (String) value;
		
		// Si la chaine est vide : false
		if(stringValue == null || stringValue.length() == 0) return false;
		
		// Obtention du tableau de valeurs
		String[] parts = stringValue.split("\\.");
		
		// Si la tableau n'a pas une taille de 4
		if(parts == null || parts.length < 4) return false;
		
		// Pattern Numerique
		Pattern pattern = Pattern.compile("\\d+");
		
		// Parcours du tableau
		for (String part : parts) {

			// Si ce n'est pas un Numerique
			if(!pattern.matcher(part).matches()) return false;
		}
		
		// On retourne true
		return true;
	}
453956
public boolean isValid() {

        boolean valid = true;

        switch (shapeType) {

            case POLYLINE_MARKERS:
                valid = ((PolylineMarkers) shape).isValid();
                break;
            case POLYGON_MARKERS:
                valid = ((PolygonMarkers) shape).isValid();
                break;
            case MULTI_POLYLINE_MARKERS:
                valid = ((MultiPolylineMarkers) shape).isValid();
                break;
            case MULTI_POLYGON_MARKERS:
                valid = ((MultiPolygonMarkers) shape).isValid();
                break;
            case COLLECTION:
                @SuppressWarnings("unchecked")
                List<GoogleMapShape> shapeList = (List<GoogleMapShape>) shape;
                for (GoogleMapShape shapeListItem : shapeList) {
                    valid = shapeListItem.isValid();
                    if (!valid) {
                        break;
                    }
                }
                break;
            default:
        }

        return valid;
    }
784681
@Override
	public boolean isValid() {
		if (_valid == null) {
			final byte[] check = bit.newArray(_validAlleles.length());
			_valid = _genes.forAll(g -> !getAndSet(check, g.getAlleleIndex()));
		}

		return _valid;
	}
561547
public boolean isValid(boolean questionIsRequired) {
		// If required and checked, other types must have text
		if (questionIsRequired && isChecked() && isOtherType && (getOtherText().length() < 1)) {
			otherTextInputLayout.setError(" ");
			return false;
		}
		otherTextInputLayout.setError(null);
		return true;
	}
1256954
@SuppressWarnings("unlikely-arg-type")
	@Override
	@Pure
	public final boolean isValidPrimitive() {
		if (this.invalidityReason != null
				&& this.invalidityReason.equals(BusPrimitiveInvalidityType.VALIDITY_NOT_CHECKED)) {
			checkPrimitiveValidity();
		}
		return this.invalidityReason == null;
	}
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);
        }

    }
1326957
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (!StringUtils.isNumeric(valueAsString)) {
      // EAN must be numeric, but that's handled by digits annotation
      return true;
    }
    if (valueAsString.length() != Gtin8Validator.GTIN8_LENGTH
        && valueAsString.length() != Gtin13Validator.GTIN13_LENGTH) {
      // EAN size is wrong, but that's handled by alternate size annotation
      return true;
    }
    // calculate and check checksum (GTIN/EAN)
    return CHECK_GTIN.isValid(valueAsString);
  }