Skip to content

Function: isArgsValidationError() ​

Check whether an error is an ArgsValidationError.

Prefer this over the args-tokens guard of the same name. Both recognize errors from another bundled copy through the Symbol.for('args-tokens.ArgsValidationError') brand that args-tokens 0.29.0 or later sets, including subclasses such as ArgResolveError that override name with the argument name. This guard additionally:

  • recognizes direct ArgsValidationError instances from copies bundling args-tokens older than 0.29.0, which do not set the brand
  • checks that code and values of an error from another copy have the expected types

The guard narrows only to ArgsValidationError: across copies, instanceof ArgResolveError still fails, so do not rely on type or schema for such errors.

Signature ​

ts
export function isArgsValidationError(error: unknown): error is ArgsValidationError

Parameters ​

NameTypeDescription
errorunknownAn unknown error

Returns ​

error is ArgsValidationError — true if the error is an ArgsValidationError

Released under the MIT License.