preventChanges
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>| Argument | Type | Description |
|---|---|---|
| fieldNames | MaybeArray<string> | |
| options | PreventChangesOptions |
| type | methods | multi |
|---|---|---|
| before, around | patch | yes |
