The mapping from a string object key to a corresponding value shape.
The shape that constrains values of
a string index signature, or null
if there's no index signature.
Creates a new ObjectShape instance.
The mapping from an object key to a corresponding value shape.
The shape that constrains values of a string index signature.
The mapping from an object key to a corresponding value shape.
The shape that constrains values of
a string index signature. If null
then values thea fall under the index signature are unconstrained.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The mode of keys handling.
Protected
_exactReturns issues which describe that an object has unknown properties.
Protected
_optionsThe issue options or the issue message.
The dictionary of shape annotations.
Readonly
inputsThe array of unique input types and values that are accepted by the shape.
Readonly
istrue
if the shape allows only Shape.parseAsync and throws an error if Shape.parse is called, or
false
if the shape can be used in both sync and async contexts.
Readonly
keysThe array of known object keys.
Readonly
keysThe mode of unknown keys handling.
The array of operations that are applied to the shape output.
Readonly
propThe mapping from an object key to a corresponding value shape.
Readonly
restThe shape that constrains values of a string index signature.
Readonly
valueThe array of property shapes, parallel to ObjectShape.keys.
Protected
_applySynchronously parses the input.
The shape input to parse.
Parsing options.
null
if input matches the output, Ok that wraps the output, or an array of captured issues.
Protected
_applyAsynchronously parses the input.
The shape input to parse.
Parsing options.
The globally unique number that identifies the parsing process.
null
if input matches the output, Ok that wraps the output, or an array of captured issues.
Protected
_applyThe callback that applies Shape.operations to the shape output value.
This method returns a promise if there are async Shape.operations.
If the shape overrides only Shape._apply and doesn't override Shape._applyAsync then it's only safe to call this method as the last statement in Shape._apply. Otherwise, it may return an unexpected promise.
If the shape overrides both Shape._apply and Shape._applyAsync then this method would always synchronously return a Result inside Shape._apply.
Protected
_cloneProtected
_getProtected
_isAdds an asynchronous operation to the shape.
The callback that asynchronously applies an operation to the shape output value.
Optional
options: ParameterizedOperationOptions<Param>The operation options.
The clone of the shape.
Adds an asynchronous operation to the shape.
The callback that asynchronously applies an operation to the shape output value.
Optional
options: OperationOptionsThe operation options.
The clone of the shape.
Adds a synchronous operation to the shape.
The callback that synchronously applies an operation to the shape output value.
Optional
options: ParameterizedOperationOptions<Param>The operation options.
The clone of the shape.
Adds a synchronous operation to the shape.
The callback that synchronously applies an operation to the shape output value.
Optional
options: OperationOptionsThe operation options.
The clone of the shape.
Allows an input value, so it is passed directly to the output.
The allowed value.
The allowed value.
Adds a synchronous operation that alters the output value without changing its type.
If you want to change the base type, consider using Shape.convert.
The callback that alters the shape output. Throw a ValidationError to notify that the alteration cannot be successfully completed.
The operation options.
The clone of the shape.
Adds a synchronous operation that alters the output value without changing its type.
If you want to change the base type, consider using Shape.convert.
The callback that alters the shape output. Throw a ValidationError to notify that the alteration cannot be successfully completed.
Optional
options: OperationOptionsThe operation options.
The clone of the shape.
Adds an asynchronous operation that alters the output value without changing its type.
If you want to change the base type, consider using Shape.convertAsync.
The callback that alters the shape output. Throw a ValidationError to notify that the alteration cannot be successfully completed.
The operation options.
The clone of the shape.
Adds an asynchronous operation that alters the output value without changing its type.
If you want to change the base type, consider using Shape.convertAsync.
The callback that alters the shape output. Throw a ValidationError to notify that the alteration cannot be successfully completed.
Optional
options: OperationOptionsThe operation options.
The clone of the shape.
Returns a shape that adds a brand to the output type.
A shape with the branded output type.
Returns undefined
if parsing fails.
Returns the fallback value if parsing fails.
The fallback value.
The value or a callback that returns a value that is returned if parsing has failed. A callback receives an input value, an array of raised issues, and parsing options.
Adds a synchronous operation that checks that the shape output satisfies a requirement.
The callback must return null
or undefined
if value is valid, or an issue or an array of issues
if value is invalid. If a callback returns an empty array, it is considered that no issues have occurred.
The callback that checks that a value satisfies a requirement and returns issues if it doesn't.
The operation options.
The clone of the shape.
Adds a synchronous operation that checks that the shape output satisfies a requirement.
The callback must return null
or undefined
if value is valid, or an issue or an array of issues
if value is invalid. If a callback returns an empty array, it is considered that no issues have occurred.
The callback that checks that a value satisfies a requirement and returns issues if it doesn't.
Optional
options: OperationOptionsThe operation options.
The clone of the shape.
Adds an asynchronous operation that checks that the shape output satisfies a requirement.
The callback must return a promise that is resolved with null
or undefined
if value is valid, or an
issue or an array of issues if value is invalid. If promise resolves with an empty array, it is
considered that no issues have occurred.
The callback that checks that a value satisfies a requirement and returns issues if it doesn't.
The operation options.
The clone of the shape.
Adds an asynchronous operation that checks that the shape output satisfies a requirement.
The callback must return a promise that is resolved with null
or undefined
if value is valid, or an
issue or an array of issues if value is invalid. If promise resolves with an empty array, it is
considered that no issues have occurred.
The callback that checks that a value satisfies a requirement and returns issues if it doesn't.
Optional
options: OperationOptionsThe operation options.
The clone of the shape.
Synchronously converts the output value of the shape.
If you want to don't want to change the base type, consider using Shape.alter.
The callback that converts the input value. Throw a ValidationError to notify that the conversion cannot be successfully completed.
The ConvertShape instance.
Asynchronously converts the output value of the shape.
If you want to don't want to change the base type, consider using Shape.alterAsync.
The callback that converts the input value asynchronously. The returned promise can be rejected with a ValidationError to notify that the conversion cannot be successfully completed.
The ConvertShape instance.
Converts the shape and its child shapes to deep partial alternatives.
Note: This method returns a shape without any operations.
The deep partial clone of the shape.
Excludes value from both input and output.
The denied value.
The excluded value.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
Returns an object shape that allows only known keys and has no index signature.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The new object shape.
Checks that the input doesn't match the shape.
The shape to which the output must not conform.
The shape to which the output must not conform.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
Merge properties from the other object shape.
Note: This method returns a shape without any operations.
If a property with the same key already exists on this object shape then it is overwritten. The index signature of this shape and its keysMode is preserved intact.
Properties to add.
The object shape which properties must be added to this object shape.
The new object shape.
Add properties to an object shape.
Note: This method returns a shape without any operations.
If a property with the same key already exists on this object shape then it is overwritten. The index signature of this shape and its keysMode is preserved intact.
The shapes of properties to add.
The properties to add.
The new object shape.
Prevents an input and output from being undefined
.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
Checks that the input doesn't match the shape.
This method works exactly as Shape.exclude at runtime, but it doesn't perform the exclusion on the type level.
The shape to which the output must not conform.
The shape to which the output must not conform.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
Replaces null
input value with an null
output value.
Replaces null
input value with a default output value.
The value that is used as the replacement for null
.
The value that should be used if an input value is null
.
Passes null
and undefined
input values directly to the output without parsing.
Replaces null
and undefined
input value with a default output value.
The value that is used as the replacement for undefined
and null
.
Optional
defaultValue: DefaultValueThe value that should be used if an input value is undefined
or null
.
Returns an object shape that doesn't have the listed keys.
Note: This method returns a shape without any operations.
The tuple of keys to omit.
The array of property keys to omit.
The new object shape.
Replaces undefined
input value with an undefined
output value.
Replaces undefined
input value with a default output value.
The value that is used as the replacement for undefined
.
The value that should be used if an input value is undefined
.
Synchronously parses the value.
The value to parse.
Optional
options: ParseOptionsParsing options.
The value that conforms the output type of the shape.
Error if the shape doesn't support the sync parsing, see Shape.isAsync.
ValidationError if any issues occur during parsing.
Asynchronously parses the value.
The value to parse.
Optional
options: ParseOptionsParsing options.
The promise that resolves with the value that conforms the output type of the shape, or rejects with a ValidationError if any issues occur during parsing.
Synchronously parses the value and returns undefined
if parsing fails.
The value to parse.
The value that conforms the output type of the shape.
Error if the shape doesn't support the sync parsing, see Shape.isAsync.
Synchronously parses the value and returns the default value if parsing fails.
The value to parse.
The default value that is returned if parsing fails.
Optional
options: ParseOptionsParsing options.
The value that conforms the output type of the shape.
Error if the shape doesn't support the sync parsing, see Shape.isAsync.
Asynchronously parses the value and returns undefined
value if parsing fails.
The value to parse.
The value that conforms the output type of the shape.
Asynchronously parses the value and returns the default value if parsing fails.
The value to parse.
The default value that is returned if parsing fails.
Optional
options: ParseOptionsParsing options.
The value that conforms the output type of the shape.
Returns an object shape with all properties marked as optional.
Note: This method returns a shape without any operations.
The new object shape.
Returns an object shape with keys marked as optional.
Note: This method returns a shape without any operations.
The array of string keys.
The array of property keys to make optional.
The new object shape.
Returns an object shape that only has properties with listed keys.
Note: This method returns a shape without any operations.
The tuple of keys to pick.
The array of property keys to pick.
The new object shape.
Returns an object shape that has an index signature that doesn't constrain values.
The new object shape.
Makes an object readonly: properties cannot be added, removed or updated at runtime.
Adds a synchronous operation that refines the shape output type with the narrowing predicate.
The narrowed output value.
The param that is passed to the operation when it is applied.
The predicate that returns true
if the value conforms the required type, or false
otherwise.
The operation options or the issue message.
The shape with the narrowed output.
Adds a synchronous operation that refines the shape output type with the narrowing predicate.
The narrowed output value.
The predicate that returns true
if the value conforms the required type, or false
otherwise.
Optional
options: Message | RefineOptionsThe operation options or the issue message.
The shape with the narrowed output.
Adds a synchronous operation that checks that the output value conforms the predicate.
The predicate that returns truthy result if the value is valid, or returns falsy result otherwise.
Optional
options: Message | ParameterizedRefineOptions<Param>The operation options or the issue message.
The clone of the shape.
Adds a synchronous operation that checks that the output value conforms the predicate.
The predicate that returns truthy result if the value is valid, or returns falsy result otherwise.
Optional
options: Message | RefineOptionsThe operation options or the issue message.
The clone of the shape.
Adds an asynchronous operation that checks that the output value conforms the predicate.
The predicate that returns a promise that resolves with a truthy result if the value is valid, or a falsy result otherwise.
Optional
options: Message | ParameterizedRefineOptions<Param>The operation options or the issue message.
The clone of the shape.
Adds an asynchronous operation that checks that the output value conforms the predicate.
The predicate that returns a promise that resolves with a truthy result if the value is valid, or a falsy result otherwise.
Optional
options: Message | RefineOptionsThe operation options or the issue message.
The clone of the shape.
Replaces an input value with an output value.
The input value to replace.
The output value that is returned if an inputValue
is received.
Returns an object shape with all properties marked as required.
The new object shape.
Returns an object shape with keys marked as required.
The array of string keys.
The array of property keys to make required.
The new object shape.
Returns an object shape that has an index signature that is constrained by the given shape.
The index signature shape.
The shape that constrains values of
a string index signature, or null
if there's no index signature.
The new object shape.
Returns an object shape that doesn't have an index signature and all unknown keys are stripped.
The new object shape.
Pipes the output of this shape to the input of another shape.
The output value.
The shape that validates the output if this shape.
The value to parse.
Optional
options: ParseOptionsParsing options.
The Ok instance if parsing has succeeded or Err if parsing has failed.
Error if the shape doesn't support the sync parsing, see Shape.isAsync.
The value to parse.
Optional
options: ParseOptionsParsing options.
The Ok instance if parsing has succeeded or Err if parsing has failed.
Defines an all-or-nothing relationship between keys where if one of the keys is present, all of them are required as well.
The keys of which, if one present, all are required.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The clone of the shape.
Defines a relationship between keys where not all peers can be present at the same time.
The keys of which, if one present, the others may not all be present.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The clone of the shape.
Defines a relationship between keys where at least one of the keys is required (and more than one is allowed).
The keys of which at least one must appear.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The clone of the shape.
Defines an exclusive relationship between a set of keys where only one is allowed but none are required.
The exclusive keys that must not appear together but where none are required.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The clone of the shape.
Constrains an object to have a null
or Object prototype.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The clone of the shape.
Defines an exclusive relationship between a set of keys where one of them is required but not at the same time.
The exclusive keys that must not appear together but where one of them is required.
Optional
options: IssueOptions | MessageThe issue options or the issue message.
The clone of the shape.
The enum shape that describes object keys.
The shape of an object.