DataSchema Class
Abstract class encapsulation for any DataSchema implementation. Pass the constructor configuration an object containing these keys:
type
- "json", "JSON", Y.DataSchema.JSON, a custom implementation object (must provide an apply method), or a custom function used as the apply method.schema
- the object containing the appropriate schema key:values for the specified type of schema parser. What you would pass as the first argument to Y.DataSchema.JSON.apply( SCHEMA, data );
This class constructor replaces the Y.DataSchema object namespace. All loaded schema parser implementations are preserved.
Methods
_init
-
config
Initialize the instance, resolve the configured schema parser implementation, and add any other properties or custom methods onto this object. Generally, the "any other properties" should be just the schema.
Parameters:
-
config
Objectobject passed in from constructor
_resolve
-
type
Resolves the configured type to an implementation object (e.g. Y.DataSchema.JSON).
Accepts type as a string, object, or function. Defalts to Y.DataSchema.Base.
If a string is supplied, an implementation is searched for as a static property of Y.DataSchema. If one cannot be found, two more attempts are made with the string in upper case and then the string with first letter capitalized.
If an object that contains a method named "apply" is passed, that object is used.
If a function is passed, that function is treated as the "apply" method of a Y.DataSchema.Base implementation.
Parameters:
-
type
Object | String | Functionschema parser implemantation, its name, or a custom apply function to use over Base implementation
Returns:
apply
-
data
Pass the data to the schema parser implementation with the configured schema.
Parameters:
-
data
Mixedinput data to be parsed by the schema implementation