Skip to content

preventChanges

Source Code | Documentation

Prevent patch service calls from changing certain fields.

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

Type declaration

ts
export type PreventChangesOptions = {
  /**
   * Customize the error that is thrown if the service tries to patch a field that is not allowed.
   *
   * If not provided, throws a `BadRequest` error with a message indicating the field that is not allowed.
   */
  error?: boolean | ((item: any, name: string) => FeathersError)
}
/**
 * Prevent patch service calls from changing certain fields.
 *
 * @see https://utils.feathersjs.com/hooks/prevent-changes.html
 */
export declare const preventChanges: (
  fieldNames: MaybeArray<string>,
  options?: PreventChangesOptions,
) => (context: HookContext, next?: _has) => Promise<any>
ArgumentTypeDescription
fieldNamesMaybeArray<string>
optionsPreventChangesOptions
typemethodsmulti
before, aroundpatchyes

Released under the MIT License.