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 database
- db.isNullable(default:- validation.isRequired ? false : true): If- falsethen this field will be made non-nullable in the database and it will never be possible to set as- null.
- validation.isRequired(default:- false): If- truethen this field can never be set to- null. It validate this when creating and updating an item through the GraphQL API or the Admin UI. It will also default- db.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 match- validation.match.regex: The regular expression
- validation.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.
- bcrypt(default:- require('bcryptjs')): A module which implements the same interface as the- bcryptjspackage, such as the native- bcryptpackage. This module will be used for all encryption routines in the- passwordfield.
import { config, list } from '@keystone-6/core';import { password } from '@keystone-6/core/fields';export default config({lists: {SomeListName: list({fields: {someFieldName: password({db: { map: 'password_field' },validation: {length: { min: 10, max: 1000 },isRequired: true,rejectCommon: true,},bcrypt: require('bcrypt'),}),/* ... */},}),/* ... */},/* ... */});