Get the schema for validation
549652
def _get_schema():
        """"""
        schema_path = os.path.join(os.path.dirname(__file__),
                                   'schema', 'scheduling_block_schema.json')
        with open(schema_path, 'r') as file:
            schema_data = file.read()
        schema = json.loads(schema_data)
        return schema
1053967
def get_jsonschema(self, context=None):
        
        schema = super(Enum, self).get_jsonschema(context=None)
        schema.pop('type')
        if self.get_attr('enum'):
            schema['enum'] = self.get_attr('enum')
        return schema
103276
def validate(ctx, schema, all_schemata):
    """"""

    database = ctx.obj['db']

    if schema is None:
        if all_schemata is False:
            log('No schema given. Read the help', lvl=warn)
            return
        else:
            schemata = database.objectmodels.keys()
    else:
        schemata = [schema]

    for schema in schemata:
        try:
            things = database.objectmodels[schema]
            with click.progressbar(things.find(), length=things.count(),
                                   label='Validating %15s' % schema) as object_bar:
                for obj in object_bar:
                    obj.validate()
        except Exception as e:

            log('Exception while validating:',
                schema, e, type(e),
                '\n\nFix this object and rerun validation!',
                emitter='MANAGE', lvl=error)

    log('Done')
1242244
def schema_val(self, messages=None):
        ""
        self._ymlproc = YAMLProcessor(self._ymlfile)
        self._schemaproc = SchemaProcessor(self._schemafile)
        valid = True

        log.debug("BEGIN: Schema-based validation for YAML '%s' with schema '%s'", self._ymlfile, self._schemafile)

        # Make sure the yml and schema have been loaded
        if self._ymlproc.loaded and self._schemaproc.loaded:
            # Load all of the yaml documents. Could be more than one in the same YAML file.
            for docnum, data in enumerate(yaml.load_all(self._ymlproc.data)):

                # Since YAML allows integer keys but JSON does not, we need to first
                # dump the data as a JSON string to encode all of the potential integers
                # as strings, and then read it back out into the YAML format. Kind of
                # a clunky workaround but it works as expected.
                data = yaml.load(json.dumps(data))

                # Now we want to get a validator ready
                v = jsonschema.Draft4Validator(self._schemaproc.data)

                # Loop through the errors (if any) and set valid = False if any are found
                # Display the error message
                for error in sorted(v.iter_errors(data)):
                    msg = "Schema-based validation failed for YAML file '" + self._ymlfile + "'"
                    self.ehandler.process(docnum, self._ymlproc.doclines, error, messages)
                    valid = False

                if not valid:
                    log.error(msg)

        elif not self._ymlproc.loaded:
            raise util.YAMLError("YAML must be loaded in order to validate.")
        elif not self._schemaproc.loaded:
            raise jsonschema.SchemaError("Schema must be loaded in order to validate.")

        log.debug("END: Schema-based validation complete for '%s'", self._ymlfile)
        return valid
276613
def validate(schema):
    """"""
    try:
        tableschema.validate(schema)
        click.echo("Schema is valid")
        sys.exit(0)
    except tableschema.exceptions.ValidationError as exception:
        click.echo("Schema is not valid")
        click.echo(exception.errors)
        sys.exit(1)
973522
def _validate_data(data, schema, validator_cls):
    
    validator = validator_cls(schema)
    _errors = defaultdict(list)
    for err in validator.iter_errors(data):
        path = err.schema_path

        # Code courtesy: Ruslan Karalkin
        # Looking in error schema path for
        # property that failed validation
        # Schema example:
        # {
        #    "type": "object",
        #    "properties": {
        #        "foo": {"type": "number"},
        #        "bar": {"type": "string"}
        #     }
        #    "required": ["foo", "bar"]
        # }
        #
        # Related err.schema_path examples:
        # ['required'],
        # ['properties', 'foo', 'type']

        if "properties" in path:
            path.remove("properties")
        key = path.popleft()

        # If validation failed by missing property,
        # then parse err.message to find property name
        # as it always first word enclosed in quotes
        if key == "required":
            key = err.message.split("'")[1]

        _errors[key].append(str(err))

    if _errors:
        _raise_exception(
            web.HTTPBadRequest,
            "Request is invalid; There are validation errors.",
            _errors)
334712
def _validate(data, schema, ac_schema_safe=True, **options):
    
    try:
        jsonschema.validate(data, schema, **options)

    except (jsonschema.ValidationError, jsonschema.SchemaError,
            Exception) as exc:
        if ac_schema_safe:
            return (False, str(exc))  # Validation was failed.
        raise

    return (True, '')
1002629
def schema(self):
        
        schema = _helpers._get_sub_prop(self._properties, ["load", "schema", "fields"])
        if schema is None:
            return
        return [SchemaField.from_api_repr(field) for field in schema]
523448
def get_schema(self, *args, **kwargs):
        

        klass = self.get_schema_class()

        # kwargs context value take precedence.
        kwargs['context'] = dict(
            self.get_schema_context(),
            **kwargs.get('context', {})
        )

        return klass(*args, strict=True, **kwargs)
692009
def getSchema(cls):
        
        schema = []
        for name, atr in cls.__attributes__:
            atr = atr.__get__(None, cls)
            if isinstance(atr, SQLAttribute):
                schema.append((name, atr))
        cls.getSchema = staticmethod(lambda schema=schema: schema)
        return schema
1197093
public function get_item_schema() {
		$schema = array(
			'$schema'    => 'http://json-schema.org/draft-04/schema#',
			'title'      => 'user',
			'type'       => 'object',
			'properties' => array(
				'id'          => array(
					'description' => __( 'Unique identifier for the resource.' ),
					'type'        => 'integer',
					'context'     => array( 'embed', 'view', 'edit' ),
					'readonly'    => true,
				),
				'username'    => array(
					'description' => __( 'Login name for the resource.' ),
					'type'        => 'string',
					'context'     => array( 'edit' ),
					'required'    => true,
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_user',
					),
				),
				'name'        => array(
					'description' => __( 'Display name for the resource.' ),
					'type'        => 'string',
					'context'     => array( 'embed', 'view', 'edit' ),
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
				),
				'first_name'  => array(
					'description' => __( 'First name for the resource.' ),
					'type'        => 'string',
					'context'     => array( 'edit' ),
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
				),
				'last_name'   => array(
					'description' => __( 'Last name for the resource.' ),
					'type'        => 'string',
					'context'     => array( 'edit' ),
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
				),
				'email'       => array(
					'description' => __( 'The email address for the resource.' ),
					'type'        => 'string',
					'format'      => 'email',
					'context'     => array( 'edit' ),
					'required'    => true,
				),
				'url'         => array(
					'description' => __( 'URL of the resource.' ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'embed', 'view', 'edit' ),
				),
				'description' => array(
					'description' => __( 'Description of the resource.' ),
					'type'        => 'string',
					'context'     => array( 'embed', 'view', 'edit' ),
					'arg_options' => array(
						'sanitize_callback' => 'wp_filter_post_kses',
					),
				),
				'link'        => array(
					'description' => __( 'Author URL to the resource.' ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'embed', 'view', 'edit' ),
					'readonly'    => true,
				),
				'nickname'    => array(
					'description' => __( 'The nickname for the resource.' ),
					'type'        => 'string',
					'context'     => array( 'edit' ),
					'arg_options' => array(
						'sanitize_callback' => 'sanitize_text_field',
					),
				),
				'slug'        => array(
					'description' => __( 'An alphanumeric identifier for the resource.' ),
					'type'        => 'string',
					'context'     => array( 'embed', 'view', 'edit' ),
					'arg_options' => array(
						'sanitize_callback' => array( $this, 'sanitize_slug' ),
					),
				),
				'registered_date' => array(
					'description' => __( 'Registration date for the resource.' ),
					'type'        => 'string',
					'format'      => 'date-time',
					'context'     => array( 'edit' ),
					'readonly'    => true,
				),
				'roles'           => array(
					'description' => __( 'Roles assigned to the resource.' ),
					'type'        => 'array',
					'context'     => array( 'edit' ),
				),
				'password'        => array(
					'description' => __( 'Password for the resource (never included).' ),
					'type'        => 'string',
					'context'     => array(), // Password is never displayed
					'required'    => true,
				),
				'capabilities'    => array(
					'description' => __( 'All capabilities assigned to the resource.' ),
					'type'        => 'object',
					'context'     => array( 'edit' ),
					'readonly'    => true,
				),
				'extra_capabilities' => array(
					'description' => __( 'Any extra capabilities assigned to the resource.' ),
					'type'        => 'object',
					'context'     => array( 'edit' ),
					'readonly'    => true,
				),
			),
		);

		if ( get_option( 'show_avatars' ) ) {
			$avatar_properties = array();

			$avatar_sizes = rest_get_avatar_sizes();
			foreach ( $avatar_sizes as $size ) {
				$avatar_properties[ $size ] = array(
					'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' ), $size ),
					'type'        => 'string',
					'format'      => 'uri',
					'context'     => array( 'embed', 'view', 'edit' ),
				);
			}

			$schema['properties']['avatar_urls']  = array(
				'description' => __( 'Avatar URLs for the resource.' ),
				'type'        => 'object',
				'context'     => array( 'embed', 'view', 'edit' ),
				'readonly'    => true,
				'properties'  => $avatar_properties,
			);
		}

		$schema['properties']['meta'] = $this->meta->get_field_schema();

		return $this->add_additional_fields_schema( $schema );
	}
812121
function validate(schema) {
        var key, item;
        for (key in schema) {
            if (schema.hasOwnProperty(key)) {
                item = schema[key];
                if (!item.text) {
                    console.error("[PreferenceManager] missing required field: 'text' of '" + key + "'");
                }
                if (!item.type) {
                    console.error("[PreferenceManager] missing required field: 'type' of '" + key + "'");
                }
                if (item.type !== "Section" && typeof item['default'] === "undefined") {
                    console.error("[PreferenceManager] missing required field: 'default' of '" + key + "'");
                }
                if (item.type === "Combo" || item.type === "Dropdown") {
                    if (item.options && item.options.length > 0) {
                        var i, len;
                        for (i = 0, len = item.options.length; i < len; i++) {
                            if (typeof item.options[i].value === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'value' of '" + key + "'");
                            }
                            if (typeof item.options[i].text === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'text' of '" + key + "'");
                            }
                        }
                    } else {
                        console.error("[PreferenceManager] missing required field or no items: 'options' of '" + key + "'");
                    }
                }
            }
        }
        return true;
    }
480372
function validateSchema(schema) {
  let errors = [];

  schema.forEach((page, index) => {
    if (!['Page', 'Result'].includes(page.type)) {
      errors = [
        ...errors,
        {
          path: ['schema', index],
          error: 'Top-level element is of invalid type. Must be Page or Result',
        },
      ];
    }

    errors = [
      ...errors,
      ...validatePage(page, ['schema', index]),
    ];
  });

  return errors;
}
1359570
function GetSchema() {
		$this->LoadSchema();
		$schema = array(
			'_model' => $this->model,
			'_table' => $this->table,
		);
		$schema = array_merge($schema, $this->schema);
		$schema['_id'] = $this->schema['_id']['field'];
		$this->Trigger('getschema', $schema);
		return $schema;
	}
56021
def get_schema(self, protocol_version):
        """"""
        const = get_const(protocol_version)
        custom_schema = vol.Schema({
            typ.value: const.VALID_SETREQ[typ]
            for typ in const.VALID_TYPES[const.Presentation.S_CUSTOM]})
        return custom_schema.extend({
            typ.value: const.VALID_SETREQ[typ]
            for typ in const.VALID_TYPES[self.type]})
462110
def validate(self, formats_dir="../formats/"):
        """"""
        #TODO: download XSD from web
        if self.inline:
            xmlschema = ElementTree.XMLSchema(ElementTree.parse(StringIO("\n".join(open(formats_dir+"dcoi-dsc.xsd").readlines()))))
            xmlschema.assertValid(self.tree)
            #return xmlschema.validate(self)
        else:
            xmlschema = ElementTree.XMLSchema(ElementTree.parse(StringIO("\n".join(open(formats_dir+"dutchsemcor-standalone.xsd").readlines()))))
            xmlschema.assertValid(self.tree)
634966
async function getSchema() {
  const fakeSchemaQueryResult = {
    rows: schemaRows,
    incomplete: false
  };
  await wait(Math.random() * 5000);
  return formatSchemaQueryResults(fakeSchemaQueryResult);
}