Class: ValidatedResource

composer-common. ValidatedResource

ValidatedResource is a Resource that can validate that property
changes (or the whole instance) do not violate the structure of
the type information associated with the instance.


new ValidatedResource(modelManager, ns, type, id, resourceValidator)

This constructor should not be called directly.
Use the Factory class to create instances.


Note: Only to be called by framework code. Applications should
retrieve instances from Factory

Parameters:
Name Type Description
modelManager ModelManager

The ModelManager for this instance

ns string

The namespace this instance.

type string

The type this instance.

id string

The identifier of this instance.

resourceValidator ResourceValidator

The validator to use for this instance

Source:
See:

Extends

  • Resource

Methods


addArrayValue(propName, value)

Adds an array property value, validating that it does not violate the model

Parameters:
Name Type Description
propName string

the name of the field

value string

the value of the property

Source:
Throws:

if the value is not compatible with the model definition for the field

Type
Error

setPropertyValue(propName, value)

Sets a property, validating that it does not violate the model

Parameters:
Name Type Description
propName string

the name of the field

value string

the value of the property

Source:
Throws:

if the value is not compatible with the model definition for the field

Type
Error

validate()

Validates the instance against its model.

Source:
Throws:
  • if the instance if invalid with respect to the model
Type
Error