Skip to content

Commit

Permalink
ValidationError
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed Jan 26, 2025
1 parent ee075d4 commit 03cccb6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/aws-cdk-lib/aws-cognito/lib/user-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Grant, IGrantable, IRole, PolicyDocument, PolicyStatement, Role, Servic
import { IKey } from '../../aws-kms';
import * as lambda from '../../aws-lambda';
import { ArnFormat, Duration, IResource, Lazy, Names, RemovalPolicy, Resource, Stack, Token } from '../../core';
import { ValidationError } from '../../core/lib/errors';

/**
* The different ways in which users of this pool can sign up or sign in.
Expand Down Expand Up @@ -1324,10 +1325,10 @@ export class UserPool extends UserPoolBase {
const passwordHistorySize = props.passwordPolicy?.passwordHistorySize;
if (passwordHistorySize !== undefined) {
if (props.featurePlan === FeaturePlan.LITE) {
throw new Error('`passwordHistorySize` can not be set when `featurePlan` is `FeaturePlan.LITE`.');
throw new ValidationError('`passwordHistorySize` can not be set when `featurePlan` is `FeaturePlan.LITE`.', this);
}
if (passwordHistorySize < 0 || passwordHistorySize > 24) {
throw new Error(`\`passwordHistorySize\` must be between 0 and 24 (received: ${passwordHistorySize})`);
throw new ValidationError(`\`passwordHistorySize\` must be between 0 and 24 (received: ${passwordHistorySize}).`, this);
}
}
return undefinedIfNoKeys({
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-cognito/test/user-pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,7 @@ describe('email MFA test', () => {
passwordPolicy: {
passwordHistorySize,
},
})).toThrow(`\`passwordHistorySize\` must be between 0 and 24 (received: ${passwordHistorySize})`);
})).toThrow(`\`passwordHistorySize\` must be between 0 and 24 (received: ${passwordHistorySize}).`);
});
});
});
Expand Down

0 comments on commit 03cccb6

Please sign in to comment.