Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ export interface PasswordPolicyOptions {
/* Set a callback function to validate a password to be accepted.
<br><br>
If used in combination with `validatorPattern`, the password must pass both to be accepted. */
validatorCallback: ?() => void;
validatorCallback: ?(password: string) => boolean;
/* Set the error message to be sent.
<br><br>
Default is `Password does not meet the Password Policy requirements.` */
Expand Down
2 changes: 1 addition & 1 deletion types/Options/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export interface AccountLockoutOptions {
}
export interface PasswordPolicyOptions {
validatorPattern?: string;
validatorCallback?: () => void;
validatorCallback?: (password: string) => boolean;
validationError?: string;
doNotAllowUsername?: boolean;
maxPasswordAge?: number;
Expand Down
15 changes: 15 additions & 0 deletions types/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ async function server() {

// $ExpectType ParseServer
await parseServer2.start();

// passwordPolicy.validatorCallback accepts (password: string) => boolean
// $ExpectType ParseServer
await ParseServer.startApp({
passwordPolicy: {
validatorCallback: (password: string): boolean => password !== 'badpw',
},
});

await ParseServer.startApp({
passwordPolicy: {
// $ExpectError
validatorCallback: (password: string): string => password,
},
});
}

function exports() {
Expand Down
Loading