-
__setDefaultProp(name, defaultValue)
-
If property with name does not exist, the default value is set.
Parameters:
Name |
Type |
Description |
name |
String
|
|
defaultValue |
*
|
|
Returns:
- The value associated with name.
-
__setProp(name, val, optionsopt)
-
Sets a value in __properties. Throws if object is locked (unless the
property is allowed to be overridden), or property with
the same name already exists and override is not allowed.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
name |
String
|
|
|
Name of the property |
val |
*
|
|
|
The value for the property |
options |
Object
|
<optional>
|
{}
|
Properties
Name |
Type |
Attributes |
Default |
Description |
allowOverride |
Boolean
|
<optional>
|
false
|
If true property override
is allowed. |
|
-
__validateRangeProperty(name, val)
-
Validate input to min/max.
Parameters:
Name |
Type |
Description |
name |
String
|
Property name |
val |
Integer
|
A non-negative integer for min/max. |
-
compile(name, compileropt, returnSchemaTooopt) → {function}
-
Returns a validator function which throws ValidationError if the value it
is asked to validate does not match the schema.
Locks the current schema.
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
|
the name of this schema (to distinguish errors) |
compiler |
*
|
<optional>
|
the ajv or equivalent JSON schema compiler to use |
returnSchemaToo |
returnSchemaToo
|
<optional>
|
whether to return jsonSchema as
well as the validator |
Returns:
function
- call on a value to validate it; throws on error
-
-
Returns:
- A copy of the Todea Schema object. Locked objects become unlocked.
-
-
Sets a default value for schema.
According to JsonSchema, default value is just metadata and does not
serve any validation purpose with in JsonSchema. External tools may
choose to use this value to setup defaults, and implementations of
JsonSchema validator may choose to validate the type of default values,
but it's not required. Since when the default is used to populate the
json, there will be something downstream that validates the json and
catches issues, we omit schema validation for simplicity.
Parameters:
Name |
Type |
Description |
d |
*
|
The default value. |
-
-
Sets a description.
Parameters:
Name |
Type |
Description |
t |
String
|
Array.<String>
|
The description of the schema. If an array
of strings are passed in, they will be joined by a space to form the
description. |
-
-
Updates schemas examples.
Parameters:
Name |
Type |
Description |
es |
Array.<(String|Array.<String>)>
|
A list of examples. Each example
may be a string, or a list of strings. In case of a list of strings, the
strings will be joined by a space character and used as one example. |
-
-
The visitable in a visitor pattern. Used for exporting schema.
Parameters:
Name |
Type |
Description |
visitor |
Exporter
|
a schema exporter. @see JSONSchemaExporter |
-
-
Parameters:
Name |
Type |
Description |
name |
String
|
Name of a property |
Returns:
- The value associated with name.
-
getValidatorAndJSONSchema() → {Object}
-
See compile.
Returns:
Object
- contains jsonSchema and assertValid
-
-
Returns:
- JSON Schema with the schema version keyword at the root level.
-
-
Locks a Todea Schema object from modifications.
-
-
Set a max property depending on schema type.
Parameters:
Name |
Type |
Description |
val |
Integer
|
A non-negative integer for min/max. |
-
-
Set a min property depending on schema type.
Parameters:
Name |
Type |
Description |
val |
Integer
|
A non-negative integer for min/max. |
-
-
Marks a schema as optional. Schemas are required by default.
-
-
Sets schemas readOnly property.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
r |
Boolean
|
<optional>
|
true
|
If the schema value should be readOnly. |
-
-
Sets a title.
Parameters:
Name |
Type |
Description |
t |
String
|
The title of the schema. |
-
-
Returns a JSON Schema. It exists for compatibility with fluent-schema.