def validate(self):
        "Validate arguments, raises UrlArgsValidationError if something is wrong"

        args = self.request.args

        if len(args) == 0:
            raise UrlArgsValidationError(
                'Mandatory arguments not found, please refer to the HTTPAPI specifications.')

        for arg in args:
            # Check for unknown args
            if arg not in self.fields:
                raise UrlArgsValidationError("Argument [%s] is unknown." % arg)

            # Validate known args and check for mandatory fields
            for field in self.fields:
                fieldData = self.fields[field]

                if field in args:
                    if isinstance(args[field][0], int) or isinstance(args[field][0], float):
                        value = str(args[field][0])
                    else:
                        value = args[field][0]

                    # Validate known args
                    if ('pattern' in self.fields[field]
                            and self.fields[field]['pattern'].match(value) is None):
                        raise UrlArgsValidationError("Argument [%s] has an invalid value: [%s]." % (
                            field, value))
                elif not fieldData['optional']:
                    raise UrlArgsValidationError("Mandatory argument [%s] is not found." % field)

        return True
dataset/ETHPy150Open jookies/jasmin/jasmin/protocols/http/validation.py/UrlArgsValidator.validate/original