Validates layout.

@param dim
the new dimension of valid area. Validation run against this
@return true, if layout during validation process has been changed.
436092
protected boolean validateLayout(Dimension dim)
    {
        if (majorAxis == X_AXIS)
        {
            majorRequest = getRequirements(X_AXIS, majorRequest);
            minorRequest = getRequirements(Y_AXIS, minorRequest);
            oldDimension.setSize(majorRequest.preferred, minorRequest.preferred);
        }
        else
        {
            majorRequest = getRequirements(Y_AXIS, majorRequest);
            minorRequest = getRequirements(X_AXIS, minorRequest);
            oldDimension.setSize(minorRequest.preferred, majorRequest.preferred);
        }

        majorReqValid = true;
        minorReqValid = true;
        majorAllocValid = true;
        minorAllocValid = true;
        return false;
    }
505234
private boolean isViewLeftAligned(ViewGroup.MarginLayoutParams layoutParams) {
		final int left =  getView().getLeft();
		boolean viewLeftAligned = left == 0 || left == layoutParams.leftMargin;
		LOGGER.trace("View is {} aligned", viewLeftAligned ? "LEFT" : "RIGHT");
		return viewLeftAligned;
	}
222724
private void validate() {
        if (host.isEmpty()) {
            throw new IllegalArgumentException("host cannot be null");
        }
        if (catalog == null) {
            throw new IllegalArgumentException("namespace cannot be null");
        }
        if (table == null) {
            throw new IllegalArgumentException("set cannot be null");
        }
        if (portList.isEmpty()) {
            if(port>0){
                port(port);
            }else{
                throw new IllegalArgumentException("port cannot be null");
            }

        }
        if (host.size() != portList.size()) {
            throw new IllegalArgumentException("Host and ports cardinality must be the same");
        }

    }
717946
@Override
	public boolean validate(final Problems problems, final String compName, final String model) {
		final String[] parts = model.split("\\.");
		boolean hasIntParts = false;
		boolean hasNonIntParts = false;
		if (model.indexOf(" ") > 0 || model.indexOf("\t") > 0) {
			problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "HOST_MAY_NOT_CONTAIN_WHITESPACE", compName, model)); // NOI18N
			return false;
		}
		if (parts.length == 0) { // the string "."
			problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "INVALID_HOST_OR_IP", compName, model)); // NOI18N
			return false;
		}
		for (int i = 0; i < parts.length; i++) {
			String s = parts[i];
			if (i == parts.length - 1 && s.contains(":")) { // NOI18N
				final String[] partAndPort = s.split(":"); // NOI18N
				if (partAndPort.length > 2) {
					problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "TOO_MANY_COLONS", compName, model)); // NOI18N
					return false;
				}
				if (partAndPort.length == 0) { // the string ":"
					problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "INVALID_HOST_OR_IP", compName, model)); // NOI18N
					return false;
				}
				s = partAndPort[0];
				if (partAndPort.length == 2) {
					try {
						Integer.parseInt(partAndPort[1]);
					} catch (final NumberFormatException nfe) {
						problems.add(ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "INVALID_PORT", compName, partAndPort[1])); // NOI18N
						return false;
					}
				}
			}
			try {
				Integer.parseInt(s);
				hasIntParts = true;
			} catch (final NumberFormatException nfe) {
				hasNonIntParts = true;
			}
			if (hasIntParts && hasNonIntParts) {
				problems.add(
						ValidationBundle.getMessage(ValidHostNameOrIPValidator.class, "ADDRESS_CONTAINS_INT_AND_NON_INT_LABELS", compName, model)); // NOI18N
				return false;
			}
		}

		final boolean validHost = hasNonIntParts && this.hostVal.validate(problems, compName, model);
		final boolean validIp = hasIntParts && this.ipVal.validate(problems, compName, model);
		return validHost || validIp;
	}
953877
private boolean validate(TextInputControl tf) {
        boolean res = tf.getText().trim().length() == 0;
        ObservableList<String> styleClass = tf.getStyleClass();
        if (res) {
            if (!styleClass.contains("error")) {
                tf.setStyle("-text-area-background: " + errorColor + ";");
                styleClass.add("error");
            }
        } else {
            // remove all occurrences:
            tf.setStyle("-text-area-background: " + defaultColor + ";");
            styleClass.removeAll(Collections.singleton("error"));
        }

        return res;
    }
732371
@Override
    public boolean validate() {
        for (ValidatorBase validator : validators) {
            // source control must be set to allow validators re-usability
            validator.setSrcControl(control);
            validator.validate();
            if (validator.getHasErrors()) {
                activeValidator.set(validator);
                return false;
            }
        }
        activeValidator.set(null);
        return true;
    }
201332
public static boolean checkDimensions(final Object object, final int dimX, final int dimY) {
        boolean hasGoodDimensions = false;
        if (object != null) {
            if (object.getClass().isArray()) {
                if (Array.getLength(object) == 0 && dimX == 0) {// is a 0D Array
                    hasGoodDimensions = true;
                } else if (object.getClass().getComponentType().isArray()) {// is a 2D Array
                    final Object line = Array.get(object, 0);
                    if (dimX * dimY == Array.getLength(object) * Array.getLength(line)) {
                        hasGoodDimensions = true;
                    }
                } else {// 1 D array
                    final int length = Array.getLength(object);
                    if (dimX == length && dimY == 0) {
                        hasGoodDimensions = true;
                    } else if (dimX * dimY == length) {
                        hasGoodDimensions = true;
                    }
                }
            } else {// not an array
                if (dimX == 1 && dimY == 0) {
                    hasGoodDimensions = true;
                }
            }
        }

        return hasGoodDimensions;
    }
954308
private void validate() {
        if (isValid != null) {
            return;
        }

        ParsingValidator v =
            new ParsingValidator(useSchema ? Languages.W3C_XML_SCHEMA_NS_URI
                                 : Languages.XML_DTD_NS_URI);
        List<Source> schemaSourceList = new ArrayList<Source>();
        if (systemId != null) {
            schemaSourceList.add(new StreamSource(systemId));
        }
        addSchemaSources(schemaSource, schemaSourceList);
        v.setSchemaSources(schemaSourceList.toArray(new Source[0]));

        try {
            ValidationResult r =
                v.validateInstance(new SAXSource(validationInputSource));
            isValid = r.isValid() ? Boolean.TRUE : Boolean.FALSE;
            for (ValidationProblem p : r.getProblems()) {
                validationProblem(p);
            }
        } catch (org.xmlunit.ConfigurationException e) {
            throw new ConfigurationException(e.getCause());
        } catch (org.xmlunit.XMLUnitException e) {
            throw new XMLUnitRuntimeException(e.getMessage(), e.getCause());
        }

        if (usingDoctypeReader && isValid == Boolean.FALSE) {
            try {
                messages.append("\nContent was: ")
                    .append(getOriginalContent(validationInputSource));
            } catch (IOException e) {
                // silent but deadly?
            }
        }
    }
765907
protected function validateLayoutStyles(array $layout)
    {
        if (isset($layout[static::PADDING_TOP])
            && (0 > $layout[static::PADDING_TOP] || 300 < $layout[static::PADDING_TOP])
        ) {
            throw new InvalidArgumentException('Invalid layout padding top');
        }

        if (isset($layout[static::PADDING_BOTTOM])
            && (0 > $layout[static::PADDING_BOTTOM] || 300 < $layout[static::PADDING_BOTTOM])
        ) {
            throw new InvalidArgumentException('Invalid layout padding bottom');
        }
    }
516284
protected boolean mightBeValidatorAnnotated() {
        for (ActionFormProperty property : propertyMap.values()) {
            final Field field = property.getPropertyDesc().getField();
            if (field == null) { // not field property
                continue;
            }
            for (Annotation anno : field.getAnnotations()) {
                if (isValidatorAnnotation(anno.annotationType())) {
                    return true; // first level only
                }
            }
        }
        return false;
    }
657693
private boolean isValidElement(String element) {

        boolean validateNewElement = Boolean.valueOf(getParamValidateNewElement()).booleanValue();
        if (ALL.equals(getParamTemplate()) || !validateNewElement) {
            return true;
        }

        return isValidTemplateElement(getParamTemplate(), element);
    }
737922
@Override
  public void validateAllocator() {
    if (topSize < 0) {
      return;
    }
    traverseAndCheck();
    for (int i = 0; i < smallBins.length; i++) {
      checkSmallBin(i);
    }
    for (int i = 0; i < treeBins.length; i++) {
      checkTreeBin(i);
    }
  }
133175
private boolean validatePast(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        int res = 0;

        if (validationObject.getClass().isAssignableFrom(java.util.Date.class))
        {
            Date today = new Date();
            Date pastDate = (Date) validationObject;

            res = pastDate.compareTo(today);
        }
        else if (validationObject.getClass().isAssignableFrom(java.util.Calendar.class))
        {

            Calendar cal = Calendar.getInstance();
            Calendar pastDate = (Calendar) validationObject;
            res = pastDate.compareTo(cal);

        }
        // else
        // {
        // ruleExceptionHandler(((Past) annotate).message());
        // }
        if (res >= 0)
        {
            throwValidationException(((Past) annotate).message());
        }

        return true;
    }
798393
public void validate() {
        // AutoResetToZero
        if (niceMinValue > 0 || niceMaxValue < 0) {
            autoResetToZero = false;
        }

        // Threshold
        if (threshold < niceMinValue || threshold > niceMaxValue) {
            threshold = niceMaxValue;
        }

        // MinMeasuredValue
        if (minMeasuredValue < niceMinValue || minMeasuredValue > niceMaxValue) {
            minMeasuredValue = value;
        }

        // MaxMeasuredValue
        if (maxMeasuredValue > niceMaxValue || maxMeasuredValue < niceMinValue) {
            maxMeasuredValue = value;
        }

        // PeakValue
        if (peakValue < niceMinValue || peakValue > niceMaxValue) {
            peakValue = value;
        }

        // TrackStart
        if (Double.compare(trackStart, niceMinValue) <= 0 || Double.compare(trackStart, niceMaxValue) >= 0 || Double.compare(trackStart, trackStop) >= 0) {
            trackStart = niceMinValue;
        }

        // TrackStop
        if ((Double.compare(trackStop, niceMinValue)) <= 0 || Double.compare(trackStop, niceMaxValue) >= 0 || Double.compare(trackStop, trackStart) <= 0) {
            trackStop = niceMaxValue;
        }

        // TrackSection
        if (Double.compare(trackSection, niceMinValue) <= 0 || Double.compare(trackSection, niceMaxValue) >= 0 || Double.compare(trackSection, trackStart) <= 0 || Double.compare(trackSection, trackStop) >= 0) {
            trackSection = ((trackStart + (trackStop - trackStart) / 2.0));
        }

        // Areas
        for (Section area : areas) {
            if ((area.getStart() < niceMinValue) || Double.compare(area.getStart(), niceMaxValue) >= 0 || Double.compare(area.getStart(), area.getStop()) >= 0) {
                area.setStart(niceMinValue);
            }

            if (area.getStop() < niceMinValue || area.getStop() > niceMaxValue || Double.compare(area.getStop(), area.getStart()) <= 0) {
                area.setStop(niceMaxValue);
            }

            if (Double.compare(area.getStart(), minValue) == 0) {
                area.setStart(niceMinValue);
            }

            if (Double.compare(area.getStop(), maxValue) == 0) {
                area.setStop(niceMaxValue);
            }
        }

        // Sections
        for (Section section : sections) {
            if ((section.getStart() < niceMinValue) || Double.compare(section.getStart(), niceMaxValue) >= 0 || Double.compare(section.getStart(), section.getStop()) >= 0) {
                section.setStart(niceMinValue);
            }

            if (section.getStop() < niceMinValue || section.getStop() > niceMaxValue || Double.compare(section.getStop(), section.getStart()) <= 0) {
                section.setStop(niceMaxValue);
            }

            if (Double.compare(section.getStart(), minValue) == 0) {
                section.setStart(niceMinValue);
            }

            if (Double.compare(section.getStop(), maxValue) == 0) {
                section.setStop(niceMaxValue);
            }
        }

        // TickmarkSections
        for (Section tickmarkSection : tickmarkSections) {
            if ((tickmarkSection.getStart() < niceMinValue) || Double.compare(tickmarkSection.getStart(), niceMaxValue) >= 0 || Double.compare(tickmarkSection.getStart(), tickmarkSection.getStop()) >= 0) {
                tickmarkSection.setStart(niceMinValue);
            }

            if (tickmarkSection.getStop() < niceMinValue || tickmarkSection.getStop() > niceMaxValue || Double.compare(tickmarkSection.getStop(), tickmarkSection.getStart()) <= 0) {
                tickmarkSection.setStop(niceMaxValue);
            }

            if (Double.compare(tickmarkSection.getStart(), minValue) == 0) {
                tickmarkSection.setStart(niceMinValue);
            }

            if (Double.compare(tickmarkSection.getStop(), maxValue) == 0) {
                tickmarkSection.setStop(niceMaxValue);
            }
        }

        // Recalculate the redrawTolerance
        redrawFactor = redrawTolerance * getRange();

        // Correct the value (needed for init with negative minValue)
        value = value < niceMinValue ? niceMinValue : (value > niceMaxValue ? niceMaxValue : value);
    }
690079
private static void check(Set<ConstraintViolation<Object>> constraintViolations) {
        Iterator<ConstraintViolation<Object>> iterator = constraintViolations.iterator();
        if (iterator.hasNext()) {
            throw new ValidationException(iterator.next().getMessage());
        }
    }
1073437
@Override
  public void validate(Message msg, ValidatorLevel validatorLevel) throws AvpNotAllowedException {
    if (validatorLevel == ValidatorLevel.OFF) {
      return;
    }

    // if its !OFF, we will go down, at least to this section
    for (AvpRepresentation ap : this.unmuttableMessageAvps.values()) {
      AvpSet innerSet = msg.getAvps().getAvps(ap.getCode(), ap.getVendorId());

      int count = 0;
      if (innerSet != null) {
        count = innerSet.size();
      }

      if (!ap.isCountValidForMultiplicity(count)) {
        throw new AvpNotAllowedException("AVP: \n" + ap + "\n, has wrong count in message - " + (count), ap.getCode(), ap.getVendorId());
      }
      // if its ALL, we need to go down deeper in AVPs
      if (validatorLevel != ValidatorLevel.ALL) {
        continue;
      }
      if (count != 0 && ap.isGrouped()) {
        // we are grouped
        validateGrouped(ap, innerSet);
      }
    }
  }
1360883
public function validateLayoutUpdateStruct(LayoutUpdateStruct $layoutUpdateStruct): void
    {
        $layoutName = is_string($layoutUpdateStruct->name) ?
            trim($layoutUpdateStruct->name) :
            $layoutUpdateStruct->name;

        if ($layoutName !== null) {
            $this->validate(
                $layoutName,
                [
                    new Constraints\NotBlank(),
                    new Constraints\Type(['type' => 'string']),
                ],
                'name'
            );
        }

        if ($layoutUpdateStruct->description !== null) {
            $this->validate(
                $layoutUpdateStruct->description,
                [
                    new Constraints\Type(['type' => 'string']),
                ],
                'description'
            );
        }
    }