Class Index | File Index

Classes


Class JSONSchema


Extends JSONInstance.

Defined in: jsv.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
JSONSchema(env, json, uri, schema)
This class binds a JSONInstance with a JSONSchema to provided context aware methods.
Method Summary
Method Attributes Method Name and Description
<static>  
JSONSchema.createEmptySchema(env)
Creates an empty schema.
 
getAttribute(key, arg)
Returns the value of the provided attribute name.
 
Returns all the attributes of the schema.
 
getLink(rel, instance)
Convenience method for retrieving a link or link object from a schema.
 
Returns the schema of the schema.
 
validate(instance, report, parent, parentSchema, name)
Validates the provided instance against the target schema and returns a Report.
Methods borrowed from class JSONInstance:
equals, getEnvironment, getProperties, getProperty, getPropertyNames, getType, getURI, getValue, getValueOfProperty, resolveURI
Class Detail
JSONSchema(env, json, uri, schema)
This class binds a JSONInstance with a JSONSchema to provided context aware methods.
Parameters:
{Environment} env
The environment this schema belongs to
{JSONInstance|Any} json
The value of the schema
{String} uri Optional
The URI of the schema. If undefined, the URI will be a randomly generated UUID.
{JSONSchema|Boolean} schema Optional
The schema to bind to the instance. If undefined, the environment's default schema will be used. If true, the instance's schema will be itself.
Method Detail
<static> {JSONSchema} JSONSchema.createEmptySchema(env)
Creates an empty schema.
Parameters:
{Environment} env
The environment of the schema
Returns:
{JSONSchema} The empty schema, who's schema is itself.

{JSONSchema|Any} getAttribute(key, arg)
Returns the value of the provided attribute name.

This method is different from JSONInstance#getProperty as the named property is converted using a parser defined by the schema's schema before being returned. This makes the return value of this method attribute dependent.

Parameters:
{String} key
The name of the attribute
{Any} arg Optional
Some attribute parsers accept special arguments for returning resolved values. This is attribute dependent.
Returns:
{JSONSchema|Any} The value of the attribute

{Object} getAttributes()
Returns all the attributes of the schema.
Returns:
{Object} A map of all parsed attribute values

{String|Object|undefined} getLink(rel, instance)
Convenience method for retrieving a link or link object from a schema. This method is the same as calling schema.getAttribute("links", [rel, instance])[0];.
Parameters:
{String} rel
The link relationship
{JSONInstance} instance Optional
The instance to resolve any URIs from
Returns:
{String|Object|undefined} If instance is provided, a string containing the resolve URI of the link is returned. If instance is not provided, a link object is returned with details of the link. If no link with the provided relationship exists, undefined is returned.
See:
JSONSchema#getAttribute

{JSONSchema} getSchema()
Returns the schema of the schema.
Returns:
{JSONSchema} The schema of the schema

{Report} validate(instance, report, parent, parentSchema, name)
Validates the provided instance against the target schema and returns a Report.
Parameters:
{JSONInstance|Any} instance
The instance to validate; may be a JSONInstance or any JavaScript value
{Report} report Optional
A Report to concatenate the result of the validation to. If undefined, a new Report is created.
{JSONInstance} parent Optional
The parent/containing instance of the provided instance
{JSONSchema} parentSchema Optional
The schema of the parent/containing instance
{String} name Optional
The name of the parent object's property that references the instance
Returns:
{Report} The result of the validation

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Nov 15 2010 19:25:59 GMT-0700 (MST)