Password
A password field represents an encrypted password value.
Options:
db.map: Adds a Prisma@mapattribute to this field which changes the column name in the databasedb.isNullable(default:validation.isRequired ? false : true): Iffalsethen this field will be made non-nullable in the database and it will never be possible to set asnull.validation.isRequired(default:false): Iftruethen this field can never be set tonull. It validate this when creating and updating an item through the GraphQL API or the Admin UI. It will also defaultdb.isNullableto false.validation.length.min(default:8): This describes the minimum length allowed. If you attempt to submit a string shorter than this, you will get a validation error.validation.length.max(default:undefined): This describes the maximum length allowed. If you attempt to submit a string longer than this, you will get a validation error.validation.match(default:undefined): This describes a pattern that values for this field must matchvalidation.match.regex: The regular expressionvalidation.match.explanation(default:${fieldLabel} must match ${validation.match.regex}): A message shown in the Admin when a value doesn't match the regex and returned as a validation error from the GraphQL API
validation.rejectCommon(default:false): Rejects passwords from a list of commonly used passwords.kdf(default:{ hash: (secret) => bcryptjs.hash(secret, 10), compare: (secret, hash) => bcryptjs.compare(secret, hash) }): An object withhashandcomparefunctions for hashing and comparing passwords. The default usesbcryptjsand rejects truncated inputs.
import{ config, list }from'@keystone-6/core';import{ password }from'@keystone-6/core/fields';exportdefaultconfig({lists:{SomeListName:list({fields:{someFieldName:password({db:{ map:'password_field'},validation:{length:{ min:10, max:1000},isRequired:true,rejectCommon:true,},}),/* ... */},}),/* ... */},/* ... */});