Schema helpers for ClayDB resources
- Functions
ClayPolicy
Class- new ClayPolicy(properties)
- policy.validate(entity, options)
- policy.format(entity)
- policy.validateToThrow(entity, options)
- policy.uniqueFilters(entity)
- policy.defaultsFor(entity)
- policy.testRestriction(restriction, value, options)
- policy.hasRestrictionFor(name)
- policy.clone()
- policy.toValues()
- policy.toDigest()
Create a ClayPolicy instance
Param | Type | Description |
---|---|---|
args | * |
Param | Type | Description |
---|---|---|
obj | * |
Type restrictions for clay entity
Constructor of ClayPolicy class
Param | Type | Description |
---|---|---|
properties | Object | Property config |
Validate an entity
Param | Type | Description |
---|---|---|
entity | ClayEntity | Entity to validate |
options | Object | Optional settings |
options.prefix | string | Error message prefix |
options.namespace | string | Namespace for each fields |
options.ignoreMissing | boolean | Ignore missing |
Format entity values. Note this method is DESTRUCTIVE.
Param | Type | Description |
---|---|---|
entity | ClayEntity | Entity to format |
Validate an entity and throw error if failed.
Param | Type | Description |
---|---|---|
entity | ClayEntity | Entity to validate |
options | Object | Optional settings |
Define unique filter objects for entity
Param | Type | Description |
---|---|---|
entity | ClayEntity | Entity to work with |
Get defaults values for an entity. This method does NOT update the passed entity
Param | Type | Description |
---|---|---|
entity | ClayEntity |
Validate a property value
Param | Type | Description |
---|---|---|
restriction | PropertyRestriction | Property restriction |
value | * | Property value |
options | Object | Optional settings |
Check if has restriction for a field
Param | Type | Description |
---|---|---|
name | string | Field name |
Clone this policy
Convert into JSON compatible values
To digest string