Input validators for this rule type.
555399
def validate_args(self):
        """"""
        base.BaseTarget.validate_args(self)
        params = self.params
        if params['extra_control_fields'] is not None:
            assert isinstance(params['extra_control_fields'], list), (
                'extra_control_fields must be a list of tuples, not %s' % type(
                    params['extra_control_fields']))
            for elem in params['extra_control_fields']:
                assert (isinstance(elem, tuple) and len(elem) == 1), (
                    'extra_control_fields must be a list of 2-element tuples. '
                    'Invalid contents: %s' % elem)
        pkgname_re = '^[a-z][a-z0-9+-.]+'
        assert re.match(pkgname_re, params['package_name']), (
            'Invalid package name: %s. Must match %s' % (
                params['package_name'], pkgname_re))
52065
def validate(self, value=None, model=None, context=None):
        
        errors = []
        for validator in self.validators:
            if value is None and not isinstance(validator, Required):
                continue

            error = validator.run(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
            if error:
                errors.append(error)

        return errors
312175
function validate( validator ) {
	/* jshint validthis:true */
	var out;
	if ( arguments.length ) {
		if ( !isFunction( validator ) ) {
			throw new TypeError( 'invalid input argument. Input argument must be a function. Value: `' + validator + '`.' );
		}
		return validator( this._db );
	}
	if ( this._validate === void 0 ) {
		return true;
	}
	out = this._validate( this._db );
	if ( out === false ) {
		return this._validate.errors;
	}
	return out;
}
1209383
def validate(self):
        """"""
        if not isinstance(self.predicate, Expression):
            raise TypeError(u'Expected Expression predicate, got: {} {}'.format(
                type(self.predicate).__name__, self.predicate))
        if not isinstance(self.if_true, Expression):
            raise TypeError(u'Expected Expression if_true, got: {} {}'.format(
                type(self.if_true).__name__, self.if_true))
        if not isinstance(self.if_false, Expression):
            raise TypeError(u'Expected Expression if_false, got: {} {}'.format(
                type(self.if_false).__name__, self.if_false))
593431
def validate(self, data):
        """"""
        validated = self._validated(data)
        errors = []
        for validator in self.additional_validators:
            if not validator(validated):
                errors.append(
                    "%s invalidated by '%s'" % (
                        validated, _get_repr(validator)))
        if errors:
            raise NotValid(*errors)

        if self.default is UNSPECIFIED:
            return validated

        if self.null_values is not UNSPECIFIED\
                and validated in self.null_values:
            return self.default

        if validated is None:
            return self.default

        return validated
1096169
def _determine_validator_type(self, data_type, value, has_default):
        """"""
        data_type, nullable = unwrap_nullable(data_type)

        validator = None

        if is_list_type(data_type):
            item_validator = self._determine_validator_type(
                data_type.data_type, value, False)
            item_validator = item_validator if item_validator else 'nil'

            validator = '{}:{}'.format(
                fmt_validator(data_type),
                fmt_func_args([
                    ('minItems', '@({})'.format(data_type.min_items)
                     if data_type.min_items else 'nil'),
                    ('maxItems', '@({})'.format(data_type.max_items)
                     if data_type.max_items else 'nil'),
                    ('itemValidator', item_validator),
                ]))
        elif is_map_type(data_type):
            item_validator = self._determine_validator_type(
                data_type.value_data_type, value, False)
            item_validator = item_validator if item_validator else 'nil'

            validator = '{}:{}'.format(
                fmt_validator(data_type),
                fmt_func_args([
                    ('itemValidator', item_validator),
                ]))
        elif is_numeric_type(data_type):
            if data_type.min_value or data_type.max_value:
                validator = '{}:{}'.format(
                    fmt_validator(data_type),
                    fmt_func_args([
                        ('minValue', '@({})'.format(data_type.min_value)
                         if data_type.min_value else 'nil'),
                        ('maxValue', '@({})'.format(data_type.max_value)
                         if data_type.max_value else 'nil'),
                    ]))
        elif is_string_type(data_type):
            if data_type.pattern or data_type.min_length or data_type.max_length:
                pattern = data_type.pattern.encode('unicode_escape').replace(
                    "\"", "\\\"") if data_type.pattern else None
                validator = '{}:{}'.format(
                    fmt_validator(data_type),
                    fmt_func_args([
                        ('minLength', '@({})'.format(data_type.min_length)
                         if data_type.min_length else 'nil'),
                        ('maxLength', '@({})'.format(data_type.max_length)
                         if data_type.max_length else 'nil'),
                        ('pattern', '@"{}"'.format(pattern)
                         if pattern else 'nil'),
                    ]))

        if nullable:
            if validator:
                validator = fmt_func_call(
                    caller='DBStoneValidators', callee=validator)
                validator = fmt_func_call(
                    caller='DBStoneValidators',
                    callee='nullableValidator',
                    args=validator)
        else:
            if validator:
                validator = fmt_func_call(
                    caller='DBStoneValidators', callee=validator)
            else:
                validator = 'nil'
            if not has_default:
                validator = fmt_func_call(
                    caller='DBStoneValidators',
                    callee='nonnullValidator',
                    args=validator)
            else:
                validator = None
        return validator
390612
def validate(self, value):
        
        for validator in self.validators:
            errors = []
            try:
                validator(value)
            except ValidationError as err:
                errors.append(err)
            if errors:
                raise ValidationError(errors)
        return value
781587
def validate(self,value):
        """"""
        if self.validator is not None:
            try:
                valid = self.validator(value)
            except Exception as e:
                import pdb; pdb.set_trace()
            if isinstance(valid, tuple) and len(valid) == 2:
                valid, errormsg = valid
            elif isinstance(valid, bool):
                errormsg = "Invalid value"
            else:
                raise TypeError("Custom validator must return a boolean or a (bool, errormsg) tuple.")
            if valid:
                self.error = None
            else:
                self.error = errormsg
            return valid
        else:
            self.error = None #reset error
            return True
343276
public List<ValidationError> validateInput() {
        List<ValidationError> errors = new ArrayList<ValidationError>();

        for (FormSectionController section : getSections()) {
            for (FormElementController element : section.getElements()) {
                if (element instanceof LabeledFieldController) {
                    LabeledFieldController field = (LabeledFieldController)element;
                    errors.addAll(field.validateInput());
                }
            }
        }

        return errors;
    }
424738
public void validate() {
        for (String in : getInputFiles()) {
            if (!new File(in).exists())
                throwValidationException("ERROR: input file \"" + in + "\" does not exist.", false);
            validateInfo(in);
        }
    }
1194913
function Validator(options) {
  options = options || {};

  this.cwd = options.cwd || process.cwd();
  this.debug = !!options.debug;
}
756879
function check(value, ...validators) {
    let valid = false;
    _.each(validators, (validator) => {
        return !(valid = validator(value));
    });

    if (!valid) {
        throw new TypeError('Argument is not any of the accepted types.');
    }
}
1096359
private static void validateInputType(Type t, TypeInformation<?> inType) {
		ArrayList<Type> typeHierarchy = new ArrayList<Type>();
		try {
			validateInfo(typeHierarchy, t, inType);
		}
		catch(InvalidTypesException e) {
			throw new InvalidTypesException("Input mismatch: " + e.getMessage(), e);
		}
	}
445761
public final void setValidator(@NonNull final Validator<Type> validator) {
        Condition.INSTANCE.ensureNotNull(validator, "The validator may not be null");
        this.validator = validator;
    }
478143
public function setupRules()
    {
        parent::setupRules();

        $this->rules->validator = new Validator(
            ['!format.block.code', '!format.monospace', '!operator.escape', '!operator', '!tag']
        );

        $this->rules->addMany([
            'format.header' => [
                new Rule(new RegexMatcher('/^\s{0,3}(#+.+?)\r?$/m')),
                new Rule(new RegexMatcher('/^([^\r\n]+?)^(?:-+|=+)\R?$/m'))
            ],
            'format.italics'   => new Rule(
                new RegexMatcher('/(?:^|[^*_])(?P<italics>(?P<i>[*_])(?>[^*_\r\n]|(?:(?P<b>[*_]{2})(?>[^*_\r\n]|(?&italics))*?\g{b}))+\g{i})/'), [
                    'italics' => Token::NAME
                ]
            ),
            'format.bold'  => new Rule(
                new RegexMatcher('/(?P<bold>(?P<b>\*\*|__)(?>[^*_\r\n]|(?:(?P<i>[*_]{2})(?>[^*_\r\n]|(?&bold))*?\g{i}))+\g{b})/', [
                    'bold' => Token::NAME
                ])
            ),
            'format.strike'    => new Rule(new RegexMatcher('/(~~.+?~~)/')),
            'format.monospace' => [
                new Rule(new RegexMatcher('/(?:[^`]|^)(`.*?`)/')),
                new Rule(new RegexMatcher('/(``.*?``)/')),
                new Rule(new RegexMatcher('/^((?:(?: {4,}|\t).*?(?>\R|$)+?)+)/m')),
            ],

            'operator.list.ordered'   => new Rule(new RegexMatcher('/^\s*(\d+[.)])/m')),
            'operator.list.unordered' => new Rule(new RegexMatcher('/^\s*([-+*])/m'), [
                'context' => ['none'],
                'priority' => 1
            ]),

            'string.quote'       => new Rule(new RegexMatcher('/((?:^>.*?\R)+)/m')),
            'format.block.code'  => [
                new Rule(
                    new DelegateRegexMatcher(
                        '/^```(.*?)\R(.*?)\R^```/ms',
                        function($match, TokenFactoryInterface $factory) {
                            $lang = KeyLighter::get()->getLanguage($match[1][0]);
                            yield $factory->create(Token::NAME, ['pos' => $match[0][1], 'length' => strlen($match[0][0])]);
                            yield $factory->create(
                                "language.{$lang->getIdentifier()}", [
                                    'pos'    => $match[2][1],
                                    'length' => strlen($match[2][0]),
                                    'inject' => $lang,
                                    'class'  => LanguageToken::class,
                                ]
                            );
                        }
                    ), [
                        'context'     => Validator::everywhere(),
                        'postProcess' => true,
                        'priority'    => 1000
                    ]
                ),
            ],

            'operator.escape' => new Rule(new RegexMatcher('/(\\\.)/')),

            'operator.horizontal' => new Rule(new RegexMatcher('/^\s{,3}(([-*_])( ?\2)+)\R/m'), [
                'priority' => 2
            ]),

            'symbol.link'  => new Rule(new RegexMatcher('/[^!](\[(?:[^\[\]]|!\[.*?\]\(.*?\))*\])/i')),
            'symbol.url'   => new Rule(new RegexMatcher('#(<(https?://|[^/])[-A-Za-z0-9+&@\#/%?=~_|!:,.;]+[-A-Za-z0-9+&@\#/%=~_|]>|https?://[-A-Za-z0-9+&@\#/%?=~_|!:,.;]+[-A-Za-z0-9+&@\#/%=~_|])#i'), [
                'priority' => 0,
            ]),
            'symbol.image' => new Rule(new RegexMatcher('/(!)(\[.*?\])\(.*?\)/i', [
                1 => 'operator.image',
                2 => '$.title',
            ])),
        ]);
    }
1137576
private function validate()
    {
        // Try to resolve subrules if there are any
        // as a final step before running the validator.
        $this->resolveSubrules();

        // Apply input filters.
        $filters = new Filters($this->inputs, $this->filters, $this);
        $this->inputs = $filters->apply();

        // Apply custom rules.
        $this->customRules();

        $this->validator = $this->validator->make($this->inputs, $this->rules, $this->messages);

        // Apply attributes.
        $this->validator->setAttributeNames($this->attributes);

        // Run the 'after' method, letting the
        // user execute code after validation.
        if (method_exists($this, 'after')) {
            $this->after($this->validator);
        }
    }
1264764
def validate(self):
        """"""
        if not (isinstance(self.start_class, set) and
                all(isinstance(x, six.string_types) for x in self.start_class)):
            raise TypeError(u'Expected set of string start_class, got: {} {}'.format(
                type(self.start_class).__name__, self.start_class))

        for cls in self.start_class:
            validate_safe_string(cls)