DataType
Extends:
Direct Subclass:
Indirect Subclass:
The base data type. Every registered data type must eventually inherit from this.
Allowed options:
| Name | Type | Attribute | Description |
|---|---|---|---|
| required | boolean |
|
Marks if this data type is required to have a value to pass validation. |
| unique | boolean |
|
Marks if this data type is required to be unique across all models. |
| generated | boolean |
|
Marks if this data type will have a value generated by the server if it is not assigned one by the client. |
| excluded | boolean |
|
Marks if this data type will be excluded from the output model. |
| defaultValue | any |
|
The default value to use if one is not provided by the user. |
| validator | function(value: any, rootValue: any): boolean |
|
A custom validation function. |
| validationLinks | string[] |
|
A list of other data types in this model to also validate when this data type is validated. |
Static Member Summary
| Static Public Members | ||
| public static |
typeName: * The data type name. |
|
Static Method Summary
| Static Public Methods | ||
| public static |
parse(field: *, parseField: *): * |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(name: string, options: Object) Creates a new instance of a data type. |
|
Method Summary
| Public Methods | ||
| public |
|
|
| public |
filter(filterValue: *, rowValue: *): * |
|
| public |
getDefaultValue(defaultValue: undefined): * |
|
| public |
getDisplay(value: *): string Returns the value parsed for human consumption. |
|
| public |
getField(ref: *): * |
|
| public |
getFieldAndValue(value: *, ref: *): {"field": *, "value": *} |
|
| public |
getName(): * |
|
| public |
getOptions(): * |
|
| public |
getValidationLinks(): * |
|
| public |
getValidator(): * |
|
| public |
getValue(value: *, defaultValue: *): * Returns a parsed value. |
|
| public |
Checks if the passed in value is "not empty". |
|
| public |
isExcluded(): * |
|
| public |
isGenerated(): * |
|
| public |
isRequired(): * |
|
| public |
isUnique(): * |
|
| public |
validate(value: *, callback: *): * Validates that the given value follows the rules of the data type. |
|
Inherited Summary
| From class Type | ||
| public static |
typeName: * The type name. |
|
| public static |
Parses a JS or Immutable.js object into a type. |
|
| public static |
parseOneOrMany(parseField: func): oneOrManyParser Creates a one or many parser with the passed in field parser. |
|
| public static |
parseOptions(field: Immutable.Map, parseField: function): Immutable.Map Override this function if you want the type to reference other types. |
|
Static Public Members
public static typeName: * source
The data type name. This must be overridden.
Override:
Type#typeNameStatic Public Methods
public static parse(field: *, parseField: *): * source
Parses a JS or Immutable.js object into a type.
Override:
Type#parseParams:
| Name | Type | Attribute | Description |
| field | * | ||
| parseField | * |
Return:
| * |
Public Constructors
Public Methods
public exclude(model: *, deep: boolean): * source
Params:
| Name | Type | Attribute | Description |
| model | * | ||
| deep | boolean |
|
Return:
| * |
public filter(filterValue: *, rowValue: *): * source
Params:
| Name | Type | Attribute | Description |
| filterValue | * | ||
| rowValue | * |
Return:
| * |
public getDefaultValue(defaultValue: undefined): * source
Params:
| Name | Type | Attribute | Description |
| defaultValue | undefined |
|
Return:
| * |
public getDisplay(value: *): string source
Returns the value parsed for human consumption.
Params:
| Name | Type | Attribute | Description |
| value | * |
public getFieldAndValue(value: *, ref: *): {"field": *, "value": *} source
Params:
| Name | Type | Attribute | Description |
| value | * | ||
| ref | * |
Return:
| {"field": *, "value": *} |
public getValue(value: *, defaultValue: *): * source
Returns a parsed value. A value of undefined implies that the value is
missing and should be filled in by a default value, first supplied in the
options, and if not, the one supplied by the type.
Params:
| Name | Type | Attribute | Description |
| value | * | ||
| defaultValue | * |
Return:
| * |
public hasValue(value: object, checkDefault: boolean): boolean source
Checks if the passed in value is "not empty".
public validate(value: *, callback: *): * source
Validates that the given value follows the rules of the data type.
Params:
| Name | Type | Attribute | Description |
| value | * | ||
| callback | * |
Return:
| * | An error if one was found, undefined otherwise. |