/* (non-Javadoc)
@see com.github.mkolisnyk.aerial.expressions.ValueExpression#validate()
170162
@Override
    public void validate() throws Exception {
        super.validate();
        this.parse();
        Assert.assertTrue("The upper date should be after the initial date",
                this.upper.after(this.lower));
    }
222573
@Override
    public void validate() throws ConfigurationException {
        if (host == null || host.length() == 0) {
            this.host = "localhost";
        }
        if (port == null || port.length() == 0) {
            this.port = "12345";
        }
    }
89225
public void validate() {
    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("missing or empty id");
    }
    Query.validateId(id);
    
    if (expr == null || expr.isEmpty()) {
      throw new IllegalArgumentException("missing or empty expr");
    }
    
    // parse it just to make sure we're happy and extract the variable names. 
    // Will throw JexlException
    parsed_expression = ExpressionIterator.JEXL_ENGINE.createScript(expr);
    variables = new HashSet<String>();
    for (final List<String> exp_list : 
      ExpressionIterator.JEXL_ENGINE.getVariables(parsed_expression)) {
      for (final String variable : exp_list) {
        variables.add(variable);
      }
    }
    
    // others are optional
    if (join == null) {
      join = Join.Builder().setOperator(SetOperator.UNION).build();
    }
  }
597430
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);

    if (StringUtils.isEmpty(valueAsString)) {
      // empty field is ok
      return true;
    }
    try {
      String countryCode = BeanUtils.getProperty(pvalue, fieldCountryCode);
      final String phoneNumber = BeanUtils.getProperty(pvalue, fieldPhoneNumber);
      if (StringUtils.isEmpty(phoneNumber)) {
        return true;
      }

      if (allowLowerCaseCountryCode) {
        countryCode = StringUtils.upperCase(countryCode);
      }
      final PathDefinitionInterface pathDefinition = GWT.create(PathDefinitionInterface.class);
      final String url =
          pathDefinition.getRestBasePath() + "/" + PhoneNumber.ROOT + "/" + PhoneNumber.VALIDATE //
              + "?" + Parameters.COUNTRY + "=" + countryCode //
              + "&" + Parameters.PHONE_NUMBER + "=" + urlEncode(phoneNumber) //
              + "&" + Parameters.DIN_5008 + "=" + PhoneNumberValueRestValidator.this.allowDin5008 //
              + "&" + Parameters.E123 + "=" + PhoneNumberValueRestValidator.this.allowE123 //
              + "&" + Parameters.URI + "=" + PhoneNumberValueRestValidator.this.allowUri //
              + "&" + Parameters.MS + "=" + PhoneNumberValueRestValidator.this.allowMs //
              + "&" + Parameters.COMMON + "=" + PhoneNumberValueRestValidator.this.allowCommon;
      final String restResult = CachedSyncHttpGetCall.syncRestCall(url);
      if (StringUtils.equalsIgnoreCase("TRUE", restResult)) {
        return true;
      }
      switchContext(pcontext);
      return false;
    } catch (final Exception ignore) {
      switchContext(pcontext);
      return false;
    }
  }
576399
public void validate(String path, Schema schema, Object value, List<ValidationResult> results) {
		String name = path != null ? path : "value";
		List<String> found = new ArrayList<String>();

		for (String property : _properties) {
			Object propertyValue = ObjectReader.getProperty(value, property);
			if (propertyValue != null)
				found.add(property);
		}

		if (found.size() == 0) {
			results.add(new ValidationResult(path, ValidationResultType.Error, "VALUE_NULL",
					name + " must have at least one property from " + _properties, _properties, null));
		}
	}
757443
private boolean validateMinValue(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        Long minValue = ((Min) annotate).value();
        if (checkvalidDigitTypes(validationObject.getClass()))
        {
            if ((NumberUtils.toLong(toString(validationObject))) < minValue)
            {

                throwValidationException(((Min) annotate).message());
            }
        }

        return true;
    }
719695
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (username == null && id == null)
            throw OpsGenieClientValidationException.missingMultipleMandatoryProperty(OpsGenieClientConstants.API.USERNAME, OpsGenieClientConstants.API.ID);
    }
113803
public void validate(Object o)
    {
        if (o != null && o instanceof String)
        {
            int l = ((String)o).length();
            if (m_minLength != -1 && l < m_minLength)
            {
                String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(), m_minLength,m_maxLength,String.valueOf(o) });
                throw new ValidationException(message);                
            }
            if (m_maxLength != -1 && l > m_maxLength)
            {
                String message = m_propertyMetadata.getMessageSourceAccessor().getMessage(m_message, new Object[]{ m_propertyMetadata.getLabelName(),m_minLength,m_maxLength, String.valueOf(o) });
                throw new ValidationException(message);                
            }
        }
    }
856836
@Override
	public boolean validate() {
		if (searchGeometry == null) {
			SC.say(messages.geometricSearchWidgetTitle(), messages.geometricSearchWidgetNoGeometry());
			return false;
		} else if (SearchCommService.getVisibleServerLayerIds(mapWidget.getMapModel()).size() < 1) {
			SC.say(messages.geometricSearchWidgetTitle(), messages.geometricSearchWidgetNoLayers());
			return false;
		} else {
			return true;
		}
	}
1153741
public void validate(String path, Schema schema, Object value, List<ValidationResult> results) {
		if (_rule == null)
			return;

		String name = path != null ? path : "value";
		List<ValidationResult> localResults = new ArrayList<ValidationResult>();
		_rule.validate(path, schema, value, localResults);
		if (localResults.size() > 0)
			return;

		results.add(new ValidationResult(path, ValidationResultType.Error, "NOT_FAILED",
				"Negative check for " + name + " failed", null, null));
	}
1250051
@Override
    public void validate(final FacesContext context) {
        // iterate over submitted values and attempt to convert to the proper
        // data type. For successful values, remove from submitted and add to
        // local values map. for failures, add a conversion message and leave in
        // the submitted state
        final Iterator<Entry<SheetRowColIndex, String>> entries = submittedValues.entrySet().iterator();
        final boolean hadBadUpdates = !getInvalidUpdates().isEmpty();
        getInvalidUpdates().clear();
        while (entries.hasNext()) {
            final Entry<SheetRowColIndex, String> entry = entries.next();
            final SheetColumn column = getColumns().get(entry.getKey().getColIndex());
            final String newValue = entry.getValue();
            final String rowKey = entry.getKey().getRowKey();
            final int col = entry.getKey().getColIndex();
            setRowVar(context, rowKey);

            // attempt to convert new value from string to correct object type
            // based on column converter. Use PF util as helper
            final Converter converter = ComponentUtils.getConverter(context, column);

            // assume string value if converter not found
            Object newValueObj = newValue;
            if (converter != null) {
                try {
                    newValueObj = converter.getAsObject(context, this, newValue);
                }
                catch (final ConverterException e) {
                    // add offending cell to list of bad updates
                    // and to a StringBuilder for error messages (so we have one
                    // message for the component)
                    setValid(false);
                    FacesMessage message = e.getFacesMessage();
                    if (message == null) {
                        message = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), e.getMessage());
                    }
                    context.addMessage(this.getClientId(context), message);

                    final String messageText = message.getDetail();
                    getInvalidUpdates()
                                .add(new SheetInvalidUpdate(getRowKeyValue(context), col, column, newValue, messageText));
                    continue;
                }
            }
            // value is fine, no further validations (again, not to be confused
            // with validators. until we have a "required" or something like
            // that, nothing else to do).
            setLocalValue(rowKey, col, newValueObj);

            // process validators on column
            column.setValue(newValueObj);
            try {
                column.validate(context);
            }
            finally {
                column.resetValue();
            }

            entries.remove();
        }
        setRowVar(context, null);

        final boolean newBadUpdates = !getInvalidUpdates().isEmpty();
        final String errorMessage = getErrorMessage();

        if (hadBadUpdates || newBadUpdates) {
            // update the bad data var if partial request
            if (context.getPartialViewContext().isPartialRequest()) {
                renderBadUpdateScript(context);
            }
        }

        if (newBadUpdates && errorMessage != null) {
            final FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessage, errorMessage);
            context.addMessage(null, message);
        }
    }
451065
@Override
    public String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)
        throws XMLStreamException
    {
        //int origStart = start;

        /* First things first; let's ensure value is not empty (all
         * white space)...
         */
        while (start < end && WstxInputData.isSpaceChar(cbuf[start])) {
            ++start;
        }
        // Empty value?
        if (start >= end) {
            return reportValidationProblem(v, "Empty NMTOKENS value");
        }

        /* Then, let's have separate handling for normalizing and
         * non-normalizing case, since latter is trivially easy case:
         */
        if (!normalize) {
            for (; start < end; ++start) {
                char c = cbuf[start];
                if (!WstxInputData.isSpaceChar(c) 
                    && !WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                    return reportInvalidChar(v, c, "not valid as NMTOKENS character");
                }
            }
            return null; // ok, all good
        }

        //boolean trimmed = (origStart != start);
        //origStart = start;

        --end; // so that it now points to the last char
        // Wouldn't absolutely have to trim trailing... but is easy to do
        while (end > start && WstxInputData.isSpaceChar(cbuf[end])) {
            --end;
            //trimmed = true;
        }

        /* Ok, now, need to check we only have valid chars, and maybe
         * also coalesce multiple spaces, if any.
         */
        StringBuilder sb = null;

        while (start <= end) {
            int i = start;
            for (; i <= end; ++i) {
                char c = cbuf[i];
                if (WstxInputData.isSpaceChar(c)) {
                    break;
                }
                if (!WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                    return reportInvalidChar(v, c, "not valid as an NMTOKENS character");
                }
            }

            if (sb == null) {
                sb = new StringBuilder(end - start + 1);
            } else {
                sb.append(' ');
            }
            sb.append(cbuf, start, (i - start));

            start = i + 1;
            // Ok, any white space to skip?
            while (start <= end && WstxInputData.isSpaceChar(cbuf[start])) {
                ++start;
            }
        }

        /* 27-Nov-2005, TSa: Could actually optimize trimming, and often
         *   avoid using StringBuilder... but let's only do it if it turns
         *   out dealing with NMTOKENS normalization shows up on profiling...
         */
        return sb.toString();
    }
1333630
protected void validateRegex(String field, String regExpression, boolean isCaseSensitive, String errorKey, String errorMessage) {
        String value = controller.getPara(field);
        if (value == null) {
        	addError(errorKey, errorMessage);
        	return ;
        }
        Pattern pattern = isCaseSensitive ? Pattern.compile(regExpression) : Pattern.compile(regExpression, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(value);
        if (!matcher.matches()) {
        	addError(errorKey, errorMessage);
        }
	}
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;
  }
1109970
protected boolean evaluate(String value) {
        if (ValidationMatcherUtils.isValidationMatcherExpression(matchingValue)) {
            try {
                ValidationMatcherUtils.resolveValidationMatcher(selectKey, value, matchingValue, context);
                return true;
            } catch (ValidationException e) {
                return false;
            }
        } else {
            return value.equals(matchingValue);
        }
    }
1331693
public void validate(JavaScriptObject newValues, final I_CmsJavaScriptObjectCallback onSuccess) {

        AsyncCallback<Map<String, String>> rpcCallback = new AsyncCallback<Map<String, String>>() {

            @SuppressWarnings("synthetic-access")
            public void onFailure(Throwable caught) {

                m_apiRoot.handleError(caught, null);
            }

            public void onSuccess(Map<String, String> result) {

                if (result == null) {
                    result = Maps.newHashMap();
                }
                onSuccess.call(CmsJsUtils.convertMapToJsObject(result));
            }
        };
        m_apiRoot.getRpcHelper().executeRpc(
            CmsXmlContentUgcApi.SERVICE.validateContent(
                m_content.getSessionId(),
                CmsJsUtils.convertJsObjectToMap(newValues),
                rpcCallback));

    }
226727
public void validate()
    {
        Dimension size = desktopPane.getSize();
        size.height -= computeDesktopIconsSpace();
        layoutInternalFrames(size);
    }