Password
A password
field represents an encrypted password value.
Options:
db.map
: Adds a Prisma@map
attribute to this field which changes the column name in the databasedb.isNullable
(default:validation.isRequired ? false : true
): Iffalse
then this field will be made non-nullable in the database and it will never be possible to set asnull
.validation.isRequired
(default:false
): Iftrue
then 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.isNullable
to 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 withhash
andcompare
functions for hashing and comparing passwords.
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,},}),/* ... */},}),/* ... */},/* ... */});