Skip to content

Interface: ReferenceOptions ​

The options of a reference created by DTO.Ref() or DTO.In(): how its key is read and how the value it resolves to is adjusted.

Extends ​

  • HierarchySeparatorOptions

Properties ​

adjust? ​

optional adjust?: (value) => any

A function adjusting the resolved value, like (value) => value + 5. The adjusted value is not validated: it must be what the rule using the reference expects. Cannot be combined with map.

Parameters ​

value ​

any

Returns ​

any


ancestor? ​

optional ancestor?: number

The starting point of the reference: 0 for the value itself, 1 for its parent (the object holding it), 2 for the grandparent… Cannot be combined with a key starting with separators ('...a').

Default ​

ts
the number of leading separators of the key, else 1

in? ​

optional in?: boolean

Whether the reference resolves to an array of values the value must be one of (what DTO.In() creates), in valid() and invalid().

Default ​

ts
false

iterables? ​

optional iterables?: boolean

Whether the path reaches into the Map and Set objects.

Default ​

ts
false

map? ​

optional map?: [any, any][]

Pairs [[from, to], …] mapping the resolved value to another one; a value not in the map is used as is. Cannot be combined with adjust.


prefix? ​

optional prefix?: object

The characters marking the kind of a reference at the start of its key.

global? ​

optional global?: string

The prefix of the references to the context validation option.

Default ​
ts
'$'

local? ​

optional local?: string

The prefix of the references to the context of an error message or a rule.

Default ​
ts
'#'

root? ​

optional root?: string

The prefix of the references to the root value being validated.

Default ​
ts
'/'

render? ​

optional render?: boolean

Whether the error messages show the resolved value instead of the name of the reference.

Default ​

ts
false

separator? ​

optional separator?: string | false

The separator of the keys in a path, or false to read the whole path as a single key.

Default ​

ts
'.'

Inherited from ​

HierarchySeparatorOptions.separator

Released under the MIT License.