Skip to content

Commit

Permalink
fix field hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi committed Jul 25, 2024
1 parent 6104291 commit a75a2fe
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/fields/types/bigInt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export function bigInt <ListTypeInfo extends BaseListTypeInfo> (config: BigIntFi
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
}
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/calendarDay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export function calendarDay <ListTypeInfo extends BaseListTypeInfo> (config: Cal
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/decimal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export function decimal <ListTypeInfo extends BaseListTypeInfo> (config: Decimal
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/float/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export function float <ListTypeInfo extends BaseListTypeInfo> (config: FloatFiel
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/integer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export function integer <ListTypeInfo extends BaseListTypeInfo> (config: Integer
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/multiselect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export function multiselect <ListTypeInfo extends BaseListTypeInfo> (
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
views: '@keystone-6/core/fields/types/multiselect/views',
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/password/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export function password <ListTypeInfo extends BaseListTypeInfo> (config: Passwo
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export function select <ListTypeInfo extends BaseListTypeInfo> (config: SelectFi
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),

Check failure on line 102 in packages/core/src/fields/types/select/index.ts

View workflow job for this annotation

GitHub Actions / Linting

Argument of type 'ValidateFieldHook<BaseListTypeInfo, "update" | "create" | "delete", string> | undefined' is not assignable to parameter of type '((r: unknown) => MaybePromise<void>) | undefined'.
update: merge(validate, config.hooks?.validate?.update),

Check failure on line 103 in packages/core/src/fields/types/select/index.ts

View workflow job for this annotation

GitHub Actions / Linting

Argument of type 'ValidateFieldHook<BaseListTypeInfo, "update" | "create" | "delete", string> | undefined' is not assignable to parameter of type '((r: unknown) => MaybePromise<void>) | undefined'.
},
},
__ksTelemetryFieldTypeName: '@keystone-6/select',
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ export function text <ListTypeInfo extends BaseListTypeInfo> (
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/fields/types/timestamp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export function timestamp <ListTypeInfo extends BaseListTypeInfo> (
...config.hooks,
validate: {
...config.hooks?.validate,
create: merge(config.hooks?.validate?.create, validate),
update: merge(config.hooks?.validate?.update, validate),
create: merge(validate, config.hooks?.validate?.create),
update: merge(validate, config.hooks?.validate?.update),
},
},
input: {
Expand Down

0 comments on commit a75a2fe

Please sign in to comment.