Class jQuery.typedValue
Represents a value with an XML Schema datatype
Defined in: jquery.datatype.js.
Constructor Attributes | Constructor Name and Description |
---|---|
jQuery.typedValue(value, datatype)
Creates a new jQuery.typedValue object.
|
Field Attributes | Field Name and Description |
---|---|
The XML Schema datatype URI for the value's datatype
|
|
The string representation of the value
|
|
<static> |
jQuery.typedValue.types
An object that holds the datatypes supported by the script.
|
The value as an object.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
jQuery.typedValue.valid(value, datatype)
Checks whether a value is valid according to a given datatype.
|
Class Detail
jQuery.typedValue(value, datatype)
Creates a new jQuery.typedValue object. This should be invoked as a method
rather than constructed using new.
intValue = jQuery.typedValue('42', 'http://www.w3.org/2001/XMLSchema#integer');
- Parameters:
- {String} value
- The string representation of the value
- {String} datatype
- The XML Schema datatype URI
- Returns:
- {jQuery.typedValue}
Field Detail
datatype
The XML Schema datatype URI for the value's datatype
representation
The string representation of the value
<static>
jQuery.typedValue.types
An object that holds the datatypes supported by the script. The properties of this object are the URIs of the datatypes, and each datatype has four properties:
- strip
- A boolean value that indicates whether whitespace should be stripped from the value prior to testing against the regular expression or passing to the value function.
- regex
- A regular expression that valid values of the type must match.
- validate
- Optional. A function that performs further testing on the value.
- value
- A function that returns a Javascript object equivalent for the value.
value
The value as an object. The type of the object will
depend on the XML Schema datatype URI specified
in the constructor. The following table lists the mappings
currently supported:
XML Schema Datatype | Value type |
---|---|
http://www.w3.org/2001/XMLSchema#string | string |
http://www.w3.org/2001/XMLSchema#boolean | bool |
http://www.w3.org/2001/XMLSchema#decimal | string |
http://www.w3.org/2001/XMLSchema#integer | int |
http://www.w3.org/2001/XMLSchema#int | int |
http://www.w3.org/2001/XMLSchema#float | float |
http://www.w3.org/2001/XMLSchema#double | float |
http://www.w3.org/2001/XMLSchema#dateTime | string |
http://www.w3.org/2001/XMLSchema#date | string |
http://www.w3.org/2001/XMLSchema#gMonthDay | string |
http://www.w3.org/2001/XMLSchema#anyURI | string |
Method Detail
<static>
{boolean}
jQuery.typedValue.valid(value, datatype)
Checks whether a value is valid according to a given datatype. The datatype must be held in the jQuery.typedValue.types object.
validDate = $.typedValue.valid(date, 'http://www.w3.org/2001/XMLSchema#date');
- Parameters:
- {String} value
- The value to validate.
- {String} datatype
- The URI for the datatype against which the value will be validated.
- Throws:
- {String}
- Errors if the datatype has not been specified in the jQuery.typedValue.types object.
- Returns:
- {boolean} True if the value is valid.