Skip to content

throwIfIsMulti

Source Code | Documentation

See also: isMulti

Throw an error if the context is multi. You can use this to early return if a user provides an array on create or id:null on patch or remove.

ts
  import { 
throwIfIsMulti
} from 'feathers-utils/hooks';

Type declaration

ts
export type ThrowIfIsMultiOptions = {
  /**
   * A predicate function to filter the contexts that should be checked for multi operations.
   * If provided, only contexts that pass this predicate will be checked for multi operations.
   */
  filter?: PredicateFn
  /**
   * Customize the error that is thrown if the context is multi and the service does not allow it.
   * If not provided, throws a `BadRequest` error.
   */
  error?: (context: HookContext) => FeathersError
}
/**
 * Throw an error if the context is multi. You can use this to early return if a user provides an array on create or id:null on patch or remove.
 *
 * @see https://utils.feathersjs.com/hooks/throw-if-is-multi.html
 */
export declare const throwIfIsMulti: <H extends HookContext = HookContext>(
  options?: ThrowIfIsMultiOptions,
) => (context: H, next?: HookContext) => Promise<any>
ArgumentTypeDescription
optionsThrowIfIsMultiOptions
typemethodsmulti
before, after, aroundcreate, update, patchyes

Released under the MIT License.