2
YUI 3.13.0 (build 508226d)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('dataschema-base', function (Y, NAME) {
11
* The DataSchema utility provides a common configurable interface for widgets to
12
* apply a given schema to a variety of data.
19
* Provides the base DataSchema implementation, which can be extended to
20
* create DataSchemas for specific data formats, such XML, JSON, text and
24
* @submodule dataschema-base
29
* Base class for the YUI DataSchema Utility.
30
* @class DataSchema.Base
35
* Overridable method returns data as-is.
38
* @param schema {Object} Schema to apply.
39
* @param data {Object} Data.
40
* @return {Object} Schema-parsed data.
43
apply: function(schema, data) {
48
* Applies field parser, if defined
51
* @param value {Object} Original value.
52
* @param field {Object} Field.
53
* @return {Object} Type-converted value.
55
parse: function(value, field) {
57
var parser = (LANG.isFunction(field.parser)) ?
58
field.parser : Y.Parsers[field.parser+''];
60
value = parser.call(this, value);
63
Y.log("Could not find parser for field " + Y.dump(field), "warn", "dataschema-json");
70
Y.namespace("DataSchema").Base = SchemaBase;
71
Y.namespace("Parsers");
74
}, '3.13.0', {"requires": ["base"]});