class staticbo.dataTypes. DataType
Source: data-types/
Serves as the base class for data type definitions.
Property
Methods
new DataType()
Creates a new data type definition. The data type instances should be frozen.
Property
read-onlyname
string
The name of the data type. The default value is the name of the constructor.
Methods
abstracthasValue(value) → boolean
Abstract method to check if the data type of the value conforms to the data type definition and it is not null.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
value |
any type |
|
The value to check. |
- Throws
-
Not implemented error: The DataType.hasValue method is not implemented.
- Returns
-
boolean
True if the value is the defined data type and not null, otherwise false.
abstractisValid([value]) → any type
Abstract method to check if the value conforms to the data type definition. Returns the value when it has the required data type. If not, but it can be converted into the required data type, then returns the converted value. Otherwise returns undefined to mark the value as invalid.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
value |
any type |
Yes |
The value to check. |
- Throws
-
Not implemented error: The DataType.check method is not implemented.
- Returns
-
any type
The value in the defined data type or null when the value is valid, otherwise undefined.