Validate an array of distribution values
 @param vals [Array[Array]] [count, value]
 @return true if valid
 @raise whichever exception is thrown first when validating
   each component of the distribution.
177707
def wf_distribution_values?(vals)
      vals.each do |times, val|
        wf_distribution_count?(times)
        wf_value?(val)
      end
      true
    end
892925
public static boolean isValid(@Nullable final String hourRanges) {
        if (hourRanges == null) {
            return true;
        }
        final StringTokenizer tok = new StringTokenizer(hourRanges, "+");
        if (tok.countTokens() == 0) {
            return false;
        }
        while (tok.hasMoreTokens()) {
            final String rangeStr = tok.nextToken();
            if (!HourRange.isValid(rangeStr)) {
                return false;
            }
        }
        return true;
    }
1235490
@Override
  public boolean containsValue(Object valObj) {
    reindexItems();

    if (valObj instanceof Integer) {
      int val = (Integer) valObj;
      for (int i = 0; i < sortedValues.length; i++) {
        if (sortedValues[i] == val) {
          return true;
        }
      }
    }
    return false;
  }
998600
public function _validation_valid_string($val, $flags = array('alpha', 'utf8'))
	{
		if ($this->_empty($val))
		{
			return true;
		}

		if ( ! is_array($flags))
		{
			if ($flags == 'alpha')
			{
				$flags = array('alpha', 'utf8');
			}
			elseif ($flags == 'alpha_numeric')
			{
				$flags = array('alpha', 'utf8', 'numeric');
			}
			elseif ($flags == 'url_safe')
			{
				$flags = array('alpha', 'numeric', 'dashes');
			}
			elseif ($flags == 'integer' or $flags == 'numeric')
			{
				$flags = array('numeric');
			}
			elseif ($flags == 'float')
			{
				$flags = array('numeric', 'dots');
			}
			elseif ($flags == 'quotes')
			{
				$flags = array('singlequotes', 'doublequotes');
			}
			elseif ($flags == 'slashes')
			{
				$flags = array('forwardslashes', 'backslashes');
			}
			elseif ($flags == 'all')
			{
				$flags = array('alpha', 'utf8', 'numeric', 'spaces', 'newlines', 'tabs', 'punctuation', 'singlequotes', 'doublequotes', 'dashes', 'forwardslashes', 'backslashes', 'brackets', 'braces');
			}
			else
			{
				return false;
			}
		}

		$pattern = ! in_array('uppercase', $flags) && in_array('alpha', $flags) ? 'a-z' : '';
		$pattern .= ! in_array('lowercase', $flags) && in_array('alpha', $flags) ? 'A-Z' : '';
		$pattern .= in_array('numeric', $flags) ? '0-9' : '';
		$pattern .= in_array('spaces', $flags) ? ' ' : '';
		$pattern .= in_array('newlines', $flags) ? "\n" : '';
		$pattern .= in_array('tabs', $flags) ? "\t" : '';
		$pattern .= in_array('dots', $flags) && ! in_array('punctuation', $flags) ? '\.' : '';
		$pattern .= in_array('commas', $flags) && ! in_array('punctuation', $flags) ? ',' : '';
		$pattern .= in_array('punctuation', $flags) ? "\.,\!\?:;\&" : '';
		$pattern .= in_array('dashes', $flags) ? '_\-' : '';
		$pattern .= in_array('forwardslashes', $flags) ? '\/' : '';
		$pattern .= in_array('backslashes', $flags) ? '\\\\' : '';
		$pattern .= in_array('singlequotes', $flags) ? "'" : '';
		$pattern .= in_array('doublequotes', $flags) ? "\"" : '';
		$pattern .= in_array('brackets', $flags) ? "\(\)" : '';
		$pattern .= in_array('braces', $flags) ? "\{\}" : '';
		$pattern = empty($pattern) ? '/^(.*)$/' : ('/^(['.$pattern.'])+$/');
		$pattern .= in_array('utf8', $flags) ? 'u' : '';

		return preg_match($pattern, $val) > 0;
	}
907379
@Nonnull
  protected static EValidity validateMessage (@Nonnull final char [] aChars)
  {
    ValueEnforcer.notNull (aChars, "Chars");

    for (final char c : aChars)
      if (c < '0' || c > '9')
        return EValidity.INVALID;
    return EValidity.VALID;
  }
314681
static final void validateValues(final float[] values) {
    for (int i = 0; i < values.length ; i++) {
      if (Float.isNaN(values[i])) {
        throw new SketchesArgumentException("Values must not be NaN");
      }
      if ((i < (values.length - 1)) && (values[i] >= values[i + 1])) {
        throw new SketchesArgumentException(
          "Values must be unique and monotonically increasing");
      }
    }
  }
812962
@Override
    protected boolean validateSettings() throws IllegalArgumentException {
        // Validate values which do not require user input first to avoid unnecesary
        // work on the user part.

        // dates
        Date startDate = getStartDate();
        Date stopDate = getStopDate();
        if (startDate != null && stopDate != null) {
            if (startDate.after(stopDate)) {
                // stop date is before the start date.
                throw new IllegalArgumentException(getLocalizedString("BL_MINDATE_AFTER_MAXDATE"));
            }
        }

        // Validate levels if specified.
        Level minLevel = getMinLevel();
        Level maxLevel = getMaxLevel();
        if (maxLevel != null && minLevel != null) {
            // We have both a max and min level. Check that the min level is
            // equal to or less than the max level
            if (minLevel.intValue() > maxLevel.intValue()) {
                // Min is greater than Max level. Report error
                throw new IllegalArgumentException(getLocalizedString("BL_MINLEVEL_GREATER_THAN_MAXLEVEL"));
            }
        }

        // Required options
        try {
            setBinaryRepositoryDir(unvalidatedRepositoryDir.getCanonicalPath());
            System.out.println(getLocalizedParmString("BL_REPOSITORY_DIRECTORY", new Object[] { getValidatedBinaryRepositoryDir() }));
        } catch (IOException e) {
            throw new IllegalArgumentException(getLocalizedParmString("BL_INVALID_REPOSITORYDIR", new Object[] { unvalidatedRepositoryDir }));
        }

        // in case of copy action, we have an unvalidatedTargetDir set
        try {
            if (unvalidatedTargetDir != null) {
                String dir = unvalidatedTargetDir.getCanonicalPath();
                setOutputRepositoryDir(dir);
                System.out.println(getLocalizedParmString("BL_TARGET_DIRECTORY", new Object[] { dir }));
            }
        } catch (IOException e) {
            throw new IllegalArgumentException(getLocalizedParmString("BL_INVALID_TARGETDIR", new Object[] { unvalidatedTargetDir }));
        }

        return false;

    }
191153
public static boolean isSorted(int[] nums) {
        boolean desc = nums[0] - nums[nums.length - 1] >= 0;
        for (int i = 0; i < nums.length - 1; i++) {
            if (!desc && nums[i] > nums[i + 1]) {
                return false;
            }
            if (desc && nums[i] < nums[i + 1]) {
                return false;
            }
        }
        return true;
    }
913527
def _validate(self,val):
        """"""
        if isinstance(self.class_, tuple):
            class_name = ('(%s)' % ', '.join(cl.__name__ for cl in self.class_))
        else:
            class_name = self.class_.__name__
        if self.is_instance:
            if not (isinstance(val,self.class_)) and not (val is None and self.allow_None):
                raise ValueError(
                    "Parameter '%s' value must be an instance of %s, not '%s'" %
                    (self.name, class_name, val))
        else:
            if not (val is None and self.allow_None) and not (issubclass(val,self.class_)):
                raise ValueError(
                    "Parameter '%s' must be a subclass of %s, not '%s'" %
                    (val.__name__, class_name, val.__class__.__name__))
236391
function uniquenessValidator(values) {
  if (values.presentAuthors) {
    values = values.presentAuthors;
  }
  values.sort();

  for (var i = 0; i < values.length - 1; i++) {
    if (values[i] === values[i+1]) {
      // can throw error or return false
      // error allows supplying more detail
      throw new Error('Duplicate value [' + values[i] + '] found in Room.presentAuthors');
    }
  }

  return true;
}
834993
public VM validate(Iterator<Split> dataSplits, TrainingParameters trainingParameters) {
        AbstractModeler modeler = MLBuilder.create(trainingParameters, configuration);

        List<VM> validationMetricsList = new LinkedList<>();
        while (dataSplits.hasNext()) {
            Split s = dataSplits.next();
            Dataframe trainData = s.getTrain();
            Dataframe testData = s.getTest();

            modeler.fit(trainData);
            trainData.close();

            modeler.predict(testData);
            VM entrySample = ValidationMetrics.newInstance(vmClass, testData);
            testData.close();

            validationMetricsList.add(entrySample);
        }
        modeler.close();

        VM avgValidationMetrics = ValidationMetrics.newInstance(vmClass, validationMetricsList);

        return avgValidationMetrics;
    }
735414
def validate(self, values):
        
        if not self.schema or (values is None and not self.schema.get('required', False)):
            return
        self.validator.validate(values)
1113914
def validate(self, value) :
        """"""
        for v in self.validators :
            v.validate(value)
        return True
1147379
def validate(self, val):
        
        if not isinstance(val, six.string_types):
            raise ValidationError("'%s' expected to be a string, got %s"
                                  % (val, generic_type_name(val)))
        if not six.PY3 and isinstance(val, str):
            try:
                val = val.decode('utf-8')
            except UnicodeDecodeError:
                raise ValidationError("'%s' was not valid utf-8")

        if self.max_length is not None and len(val) > self.max_length:
            raise ValidationError("'%s' must be at most %d characters, got %d"
                                  % (val, self.max_length, len(val)))
        if self.min_length is not None and len(val) < self.min_length:
            raise ValidationError("'%s' must be at least %d characters, got %d"
                                  % (val, self.min_length, len(val)))

        if self.pattern and not self.pattern_re.match(val):
            raise ValidationError("'%s' did not match pattern '%s'"
                                  % (val, self.pattern))
        return val
1277470
@Override
    public boolean isValid(String wert) {
        if (StringUtils.length(wert) < 1) {
            return false;
        } else {
            return getPruefziffer(wert).equals(berechnePruefziffer(wert.substring(0, wert.length() - 1)));
        }
    }
505570
private boolean checkForVariables(List<Map<String, String>> values) {
    if (values == null || values.isEmpty()) {
      return false;
    } else {
      for (Map<String, String> list : values) {
        if (list.containsKey("type") && list.get("type")
            .equals(MtasParserMapping.PARSER_TYPE_VARIABLE)) {
          return true;
        }
      }
    }
    return false;
  }
1144370
def validate(self, val):
        """"""
        if self.validation:
            self.type.validate(val)

            if self.custom_validator is not None:
                self.custom_validator(val)

        return True