new Schema(definition)
js-data's Schema class.
import {Schema} from 'js-data'
Parameters:
Name | Type | Description |
---|---|---|
definition |
Object | Schema definition according to json-schema.org |
Extends
Members
-
<static> typeGroupValidators :Object
-
TODO
Type:
- Object
-
<static> types :Object
-
TODO
Type:
- Object
-
<static> validationKeywords :Object
-
TODO
Type:
- Object
-
_listeners :Object
-
Event listeners attached to this Component. Do not modify. Use Component#on and Component#off instead.
Type:
- Object
- Inherited From:
- Source:
Methods
-
<static> validate(value, schema, opts)
-
TODO
Parameters:
Name Type Argument Description value
* TODO
schema
Object <optional>
TODO
opts
Object <optional>
Configuration options.
-
dbg()
-
TODO
- Inherited From:
- Source:
-
emit(event, args)
-
Trigger an event on this Component.
Parameters:
Name Type Argument Description event
string Name of event to emit.
args
* <optional>
<repeatable>
Arguments to pass to any listeners.
- Inherited From:
- Source:
-
log()
-
TODO
- Inherited From:
- Source:
-
off(event, listener)
-
Remove an event listener from this Component. If no listener is provided, then all listeners for the specified event will be removed. If no event is specified then all listeners for all events will be removed.
Parameters:
Name Type Argument Description event
string <optional>
Name of event to unsubsribe to.
listener
function <optional>
Listener to remove.
- Inherited From:
- Source:
-
on(event, listener, ctx)
-
Register a new event listener on this Component.
Parameters:
Name Type Argument Description event
string Name of event to subsribe to.
listener
function Listener function to handle the event.
ctx
* <optional>
Optional content in which to invoke the listener.
- Inherited From:
- Source:
-
validate(target)
-
This adds ES5 getters/setters to the target based on the "properties" in this Schema, which makes possible change tracking and validation on property assignment.
Parameters:
Name Type Description target
Object The prototype to which to apply this schema.
-
validate(value, opts)
-
Validate the provided value against this schema.
Parameters:
Name Type Argument Description value
* Value to validate.
opts
Object <optional>
Configuration options.
Returns:
Array of errors or
undefined
if valid.- Type
- array | undefined