Validates arguments.
321861
def validate_args(self):
        
        from ..mixins import ModelMixin

        for arg in ("instance", "decider", "identifier", "fields", "default_language"):
            if getattr(self, arg) is None:
                raise AttributeError("%s must not be None" % arg)

        if not isinstance(self.instance, (ModelMixin,)):
            raise ImproperlyConfigured('"instance" argument must be a Linguist model')

        if not issubclass(self.decider, (models.Model,)):
            raise ImproperlyConfigured(
                '"decider" argument must be a valid Django model'
            )
458512
function assertArguments(options, argnames) {
  if (!argnames) return;
  if (!options) throw new TypeError('missing arguments: ' + argnames);
  argnames.forEach(function (argname) {
    if (!options.hasOwnProperty(argname)) {
      throw new TypeError('missing argument: ' + argname);
    }
  });
}
727190
def validate_options(self, k, v):
        """"""

        super().validate_options(k, v)
        if k == 'mode' and v not in MODE:
            raise ValueError("{}: '{}' is not a valid value for '{}'".format(self.__class__.__name, v, k))
701690
def _check_arguments(self):
        """"""
        if self.argument_checked:
            return

        assert(self.symbol is not None)
        self.argument_checked = True

        # check if symbol contain duplicated names.
        _check_arguments(self.symbol)
        # rematch parameters to delete useless ones
        if self.allow_extra_params:
            if self.arg_params:
                arg_names = set(self.symbol.list_arguments())
                self.arg_params = {k : v for k, v in self.arg_params.items()
                                   if k in arg_names}
            if self.aux_params:
                aux_names = set(self.symbol.list_auxiliary_states())
                self.aux_params = {k : v for k, v in self.aux_params.items()
                                   if k in aux_names}
276294
protected function validateArgs()
    {
        $message = null;
        foreach ($this->getMandatoryArgs() as $arg) {
            if (!isset($this->args[$arg])) {
                $message = "Argument $arg was not present in supplied job args for job " . get_class($this);
                $this->errorLog($message);
                throw new \Exception($message);
            }
        }
        if ($this->configRequired) {
            $this->ensureConfig();
        }
    }
281643
protected void validateArgumentList(String[] args) {
        checkRequiredArguments(args);

        // Skip the first argument as it is the task name
        // Arguments and values come in pairs (expect -password).
        // Anything outside of that pattern is invalid.
        // Loop through, jumping in pairs except when we encounter
        // -password -- that may be an interactive prompt which won't
        // define a value.
        for (int i = 1; i < args.length; i++) {
            String argPair = args[i];
            String arg = null;
            String value = null;
            if (argPair.contains("=")) {
                arg = argPair.split("=")[0];
                value = getValue(argPair);
            } else {
                arg = argPair;
            }

            if (!isKnownArgument(arg)) {
                throw new IllegalArgumentException(getMessage("invalidArg", arg));
            } else {
                if (value == null) {
                    throw new IllegalArgumentException(getMessage("missingValue", arg));
                }
            }
        }
    }
314805
public function validate($args)
    {
        $check = $this->normalizeArgs(is_array($args) ? $args : []);

        return is_array($check) ? true : $check;
    }
685157
def validate_args(args):
    """"""
    # Check correctness of similarity dataset names
    for dataset_name in args.similarity_datasets:
        if dataset_name.lower() not in map(
                str.lower,
                nlp.data.word_embedding_evaluation.word_similarity_datasets):
            print('{} is not a supported dataset.'.format(dataset_name))
            sys.exit(1)

    # Check correctness of analogy dataset names
    for dataset_name in args.analogy_datasets:
        if dataset_name.lower() not in map(
                str.lower,
                nlp.data.word_embedding_evaluation.word_analogy_datasets):
            print('{} is not a supported dataset.'.format(dataset_name))
            sys.exit(1)
1167716
def run_check(self, check, argument_names):
        """"""
        arguments = []
        for name in argument_names:
            arguments.append(getattr(self, name))
        return check(*arguments)
154441
def validate(self, instance):
        """"""
        errors = {}
        self._validate_instance(instance, errors)

        if len(errors) > 0:
            raise ValidationException(errors)
596025
def validate(self, value):
        """"""

        # check choices
        if self.choices:
            if isinstance(self.choices[0], (list, tuple)):
                option_keys = [k for k, v in self.choices]
                if value not in option_keys:
                    msg = ('Value {0} is not listed among valid choices {1}'.format(value, option_keys))
                    self.raise_error(msg)
            elif value not in self.choices:
                msg = ('Value {0} is not listed among valid choices {1}'.format(value, self.choices))
                self.raise_error(msg)
1046280
def validate_arguments(args):
    """"""

    #check arguments
    print
    print "Checking input...",

    semantic_tests = ["animals", "custom"]
    phonemic_tests = ["a", "p", "s", "f"]
    if args.similarity_file:
        print
        print "Custom similarity file was specified..."
        args.semantic = "custom"

    if args.threshold:
        try:
            args.threshold = float(args.threshold)
        except ValueError:
            raise VFClustException('Custom threshold (--threshold argument) must be a number.')


    if not (args.source_file_path.lower().endswith('csv') or args.source_file_path.lower().endswith('textgrid')):
        raise VFClustException('The input must be either a .TextGrid or .csv file!\nYou provided ' + args.source_file_path.lower())
    if not os.path.isfile(args.source_file_path):
        raise VFClustException('The input file path you provided does not exist on your system!')

    #if no output path provided, write to source file path
    if args.output_path == None:
        args.output_path = args.source_path
    #if output_path is False, don't output anything
    elif args.output_path == False:
        pass
    else:
        #verify/make folders for output
        if len(args.output_path) == 0:
            args.output_path = os.path.abspath(os.path.dirname(args.source_file_path))
        try:
            if not os.path.isdir(args.output_path):
                os.mkdir(args.output_path)
        except:
            print "Error creating folder for program output. " \
                  "Make sure you have write permissions to the folder you provided. " \
                  "You can change the folder with the -o option." \
                  "The output directory will be the same as the input directory."


    #make phonemic and semantic args lower case
    if (args.semantic): args.semantic = args.semantic.lower()
    if (args.phonemic): args.phonemic = args.phonemic.lower()

    #must choose either semantic or phonemic
    if not (args.semantic or args.phonemic):
        print "DEBUG", args.semantic, args.similarity_file
        raise VFClustException(
            '''You must specify at least one phonemic or semantic test to run using -p or -s, followed by the test type.
            Alternatively, provide a custom similarity file using the --similarity-file and --threshold options.''')

    #make sure semantic arguments are legit
    if args.semantic and args.semantic not in semantic_tests:
        raise VFClustException("Currently only " + ",".join(semantic_tests) + " are supported for semantic testing. " \
                                                       "You provided " + args.semantic)

    if args.phonemic and args.phonemic not in phonemic_tests:
        raise VFClustException("Currently only " + ",".join(phonemic_tests) + " are supported for phonemic testing.  " \
                                                       "You provided " + args.phonemic)


    if (args.phonemic and args.semantic):
        raise VFClustException("You must choose EITHER semantic OR phonemic clustering.")

    #make paths absolute
    args.source_file_path = os.path.abspath(args.source_file_path)
    if args.output_path:
        args.output_path = os.path.abspath(args.output_path)

    #using custom similarity file
    if args.similarity_file: #if it's not None
        if not os.path.isfile(args.similarity_file):
            raise VFClustException('The custom similarity file path you provided does not exist on your system!')
        if not args.threshold:
            raise VFClustException('You must specify a clustering threshold when using a custom similarity file. Use --threshold X, where X is the threshold number.')
        try:
            args.threshold = float(args.threshold)
        except:
            raise VFClustException('Error reading the custom threshold you provided. It must be a number, e.g. --threshold 6.7 or --threshold 10')
        args.similarity_file = os.path.abspath(args.similarity_file)

    print "OK!"
    print
    print "Parsed arguments:"
    print_table([(k, str(vars(args)[k])) for k in vars(args)])

    return args
209214
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var start
    , end;

  if(args.length !== 1 && args.length !== 3) {
    throw new CommandArgLength(cmd);
  }

  if(args.length > 1) {
    start = parseInt('' + args[1]);
    if(isNaN(start)) throw IntegerRange;
    args[1] = start;
    end = parseInt('' + args[2]);
    if(isNaN(end)) throw IntegerRange;
    args[2] = end;
  }
}
841550
def validate_args(args):
    
    if not os.path.isdir(args.directory):
        print "Directory {} does not exist".format(args.directory)
        sys.exit(5)
    return args
840716
def _validate(self, args, kwargs):
    """"""
    def error(exception_type, arg_name=None, **msg_kwargs):
      if arg_name is None:
        arg_name = args[0] if args else '<unknown>'
      raise exception_type(self.scope, arg_name, **msg_kwargs)

    if not args:
      error(NoOptionNames)
    # validate args.
    for arg in args:
      if not arg.startswith('-'):
        error(OptionNameDash, arg_name=arg)
      if not arg.startswith('--') and len(arg) > 2:
        error(OptionNameDoubleDash, arg_name=arg)

    # Validate kwargs.
    if 'implicit_value' in kwargs and kwargs['implicit_value'] is None:
      error(ImplicitValIsNone)

    # Note: we check for list here, not list_option, because we validate the provided kwargs,
    # not the ones we modified.  However we temporarily also allow list_option, until the
    # deprecation is complete.
    if 'member_type' in kwargs and kwargs.get('type', str) not in [list, list_option]:
      error(MemberTypeNotAllowed, type_=kwargs.get('type', str).__name__)

    if kwargs.get('member_type', str) not in self._allowed_member_types:
      error(InvalidMemberType, member_type=kwargs.get('member_type', str).__name__)

    for kwarg in kwargs:
      if kwarg not in self._allowed_registration_kwargs:
        error(InvalidKwarg, kwarg=kwarg)

      # Ensure `daemon=True` can't be passed on non-global scopes (except for `recursive=True`).
      if (kwarg == 'daemon' and self._scope != GLOBAL_SCOPE and kwargs.get('recursive') is False):
        error(InvalidKwargNonGlobalScope, kwarg=kwarg)

    removal_version = kwargs.get('removal_version')
    if removal_version is not None:
      validate_deprecation_semver(removal_version, 'removal version')
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.');
    }
}
1214547
function validate(rules, args, cb) {
  try {
    _known(rules, args);
    _required(rules, args);

    Object.keys(args).forEach(function (arg) {

      var value = args[arg],
        ruleSet = rules[arg];

      try {
        ruleSet.forEach(function (rule) {
          if (rule !== 'required') {
            exports.checks[rule](value || '');
          }
        });
      } catch (e) {
        throw new Error(util.format(
          'Validation error - arg: %s, value: %s, desc: %s',
          arg, value, e.message));
      }
    });
    cb();
  } catch (e) {
    cb(e);
  }
}