A schema value is the individual property of the schema.
new SchemaValue(type, required, defaultValue)
A supported value Javascript type
Whether the value is required
None
Name | Description | Async | Arguments | Return |
---|---|---|---|---|
toJSON |
Get a JSON representation os the value |
no | None |
JSONValue |
toString |
Get a string representation os the value |
no | None |
string |
Error thrown when the type specified is not a supported type.
// function is not a valid type
new SchemaValue(Function)
Error thrown when the default value does not match the type.
// type is String but defaultValue is number
new SchemaValue(String, false, 12)
new SchemaValue(Schema, false, {})
new SchemaValue(SchemaId, true)
new SchemaValue(ArrayOf(OneOf([String, Number], "")), false, [0, 1, 2])
new SchemaValue(Array, true)
new SchemaValue(Int32Array)
new SchemaValue(Date)
const todoSchema = new Schema<ToDo>("todo");
new SchemaValue(todoSchema, true)