You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked around for a similar issue/discussion but didn't see one, apologies if this is a duplicate.
At the moment, it appears to be impossible to use the new validate.{create|update|delete} field-level hooks with most of the built-in Keystone field types.
This appears to be due to this list check which asserts the mutual exclusivity of the new validate syntax and the old validate syntax.
Most of the built-in fields define a validateInput check that's automatically added if db.isNullable is set to false or if you specify validation options (example). Attempting to define a custom validate.create/validate.update check results in the following error:
TypeError: "hooks.validate" conflicts with "hooks.validateInput" for the "name" field
at parseFieldHooks (myapp/node_modules/@keystone-6/core/dist/createSystem-b6c61fe6.cjs.dev.js:3793:50)
at getListsWithInitialisedFields (myapp/node_modules/@keystone-6/core/dist/createSystem-b6c61fe6.cjs.dev.js:3871:16)
at initialiseLists (myapp/node_modules/@keystone-6/core/dist/createSystem-b6c61fe6.cjs.dev.js:4305:25)
at Object.createSystem (myapp/node_modules/@keystone-6/core/dist/createSystem-b6c61fe6.cjs.dev.js:4548:17)
Given that the validateInput/validateDelete syntax has been marked as deprecated (at least code comments seem to indicate that), I expected the built-in fields to allow usage of the new syntax (maybe it would make sense to have them automatically switch based on the presence of the validate object?)
Happy to submit a PR for this, but figured I'd also file an issue.
The text was updated successfully, but these errors were encountered:
acburdine
changed the title
Unable to use new validate.{create|update|delete} field-level hooks with most fields
Unable to use new validate.{create|update|delete} field-level hooks with most built-in fields
Jun 5, 2024
acburdine
added a commit
to acburdine/keystone
that referenced
this issue
Jun 5, 2024
closeskeystonejs#9165
- this updates the built-in fields using validateInput to use the new unified validation syntax, and handles merging with the old syntax to ensure user-land old syntax still works
I looked around for a similar issue/discussion but didn't see one, apologies if this is a duplicate.
At the moment, it appears to be impossible to use the new
validate.{create|update|delete}
field-level hooks with most of the built-in Keystone field types.This appears to be due to this list check which asserts the mutual exclusivity of the new validate syntax and the old validate syntax.
Most of the built-in fields define a
validateInput
check that's automatically added ifdb.isNullable
is set to false or if you specify validation options (example). Attempting to define a custom validate.create/validate.update check results in the following error:Given that the validateInput/validateDelete syntax has been marked as deprecated (at least code comments seem to indicate that), I expected the built-in fields to allow usage of the new syntax (maybe it would make sense to have them automatically switch based on the presence of the validate object?)
Happy to submit a PR for this, but figured I'd also file an issue.
Keystone Version: latest (6.1.0)
Node Version: v20
The text was updated successfully, but these errors were encountered: