2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
Code licensed under the BSD License:
4
http://developer.yahoo.com/yui/license.html
8
YUI.add('dataschema-base', function(Y) {
11
* The DataSchema utility provides a common configurable interface for widgets to
12
* apply a given schema to a variety of data.
18
* Provides the base DataSchema implementation, which can be extended to
19
* create DataSchemas for specific data formats, such XML, JSON, text and
23
* @submodule dataschema-base
28
* Base class for the YUI DataSchema Utility.
29
* @class DataSchema.Base
34
* Overridable method returns data as-is.
37
* @param schema {Object} Schema to apply.
38
* @param data {Object} Data.
39
* @return {Object} Schema-parsed data.
42
apply: function(schema, data) {
47
* Applies field parser, if defined
50
* @param value {Object} Original value.
51
* @param field {Object} Field.
52
* @return {Object} Type-converted value.
54
parse: function(value, field) {
56
var parser = (LANG.isFunction(field.parser)) ?
57
field.parser : Y.Parsers[field.parser+''];
59
value = parser.call(this, value);
68
Y.namespace("DataSchema").Base = SchemaBase;
69
Y.namespace("Parsers");
73
}, '3.3.0' ,{requires:['base']});