Skip to content

fix(form): display store password complexity requirements in registration form tooltip#2814

Merged
matthewvolk merged 1 commit intocanaryfrom
CATALYST-1605-respect-store-pw-complexity-settings
Jan 8, 2026
Merged

fix(form): display store password complexity requirements in registration form tooltip#2814
matthewvolk merged 1 commit intocanaryfrom
CATALYST-1605-respect-store-pw-complexity-settings

Conversation

@matthewvolk
Copy link
Contributor

What/Why?

This PR fixes an issue where the password validation tooltip during customer registration showed hardcoded password complexity requirements instead of the actual requirements configured in the store's BigCommerce Control Panel (Settings > Security & Privacy).

Solution:

  • Extended the RegisterCustomerQuery GraphQL query to fetch passwordComplexitySettings from the BigCommerce API
  • Modified the password validation schema to accept and apply dynamic complexity settings
  • Updated the form component chain to thread password complexity settings from the server through to client-side validation
  • Password validation now dynamically generates appropriate rules and error messages based on store configuration

Testing

  1. Go to your store's Control Panel → Settings → Security & Privacy
  2. Set custom password complexity (e.g., Minimum Characters: 10, Special Characters: 3)
  3. Navigate to the registration page on your Catalyst storefront
  4. Start typing in the password field with a simple password like "test"
  5. Expected: The validation tooltip should immediately show your custom requirements (e.g., "Be at least 10 characters long", "Contain at least 3 special characters")
  6. Enter a password that matches the tooltip requirements
  7. Expected: Form validates successfully without server errors

Using the following store settings:
Screenshot 2026-01-07 at 12 36 23 PM

With password set to "a":
Screenshot 2026-01-07 at 12 23 01 PM

With password set to "a1":
Screenshot 2026-01-07 at 12 35 55 PM

With all complexity requirements met:
Screenshot 2026-01-07 at 12 36 05 PM

Migration

Breaking Changes: None - all changes are backward compatible.

What Changed: The schema() function in core/vibes/soul/form/dynamic-form/schema.ts now accepts an optional second parameter passwordComplexity to enable dynamic password validation. The DynamicForm, DynamicFormSection components and their associated server actions also accept an optional passwordComplexity prop that flows through to the schema.

Action Required: If you have custom registration or password forms and want to use store-specific password complexity settings, fetch passwordComplexitySettings from the GraphQL API (under site.settings.customers.passwordComplexitySettings) and pass it to your DynamicFormSection component and maintain it in your server action's state. If you don't pass it, password validation defaults to: minimum 8 characters, at least one number, and at least one special character.

Conflict Resolution: If merging into custom forms, ensure the passwordComplexity prop is threaded through: Page → DynamicFormSectionDynamicFormuseActionStateschema(). In server actions, add passwordComplexity?: Parameters<typeof schema>[1] to your state type and include it in all return statements to maintain state consistency.

@matthewvolk matthewvolk requested a review from a team as a code owner January 7, 2026 18:41
@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2026

🦋 Changeset detected

Latest commit: 3ed08b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
catalyst Ready Ready Preview, Comment Jan 7, 2026 6:42pm

>;

function getFieldSchema(field: Field) {
// eslint-disable-next-line complexity
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can refactor to abstract the new logic into a smaller function if we don't want this here

@jamesqquick
Copy link
Contributor

testing the functionality locally and it worked correctly for me!


function getFieldSchema(field: Field) {
// eslint-disable-next-line complexity
function getFieldSchema(field: Field, passwordComplexity?: PasswordComplexitySettings | null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about falling back to the old password complexity limits if this is null or in some weird case undefined?

Copy link
Contributor Author

@matthewvolk matthewvolk Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this yesterday! I think it's taken care of. Basically, I have a fallback for each of the different requirements, and they should match the original hardcoded (minLength of 8, requireNumbers true, etc.). Copy/pasted below for convenience:

/**
 * Original fieldSchema for reference:
 * 
 * fieldSchema = z
 *   .string()
 *   .min(8, { message: 'Be at least 8 characters long' })
 *   .regex(/[a-zA-Z]/, { message: 'Contain at least one letter.' })
 *   .regex(/[0-9]/, { message: 'Contain at least one number.' })
 *   .regex(/[^a-zA-Z0-9]/, {
 *     message: 'Contain at least one special character.',
 *   }
 */

// New 
const minLength = passwordComplexity?.minimumPasswordLength ?? 8;
const minNumbers = passwordComplexity?.minimumNumbers ?? 0;
const minSpecialChars = passwordComplexity?.minimumSpecialCharacters ?? 0;
const requireLowerCase = passwordComplexity?.requireLowerCase ?? false;
const requireUpperCase = passwordComplexity?.requireUpperCase ?? false;
const requireNumbers = passwordComplexity?.requireNumbers ?? true;
const requireSpecialChars = passwordComplexity?.requireSpecialCharacters ?? true;

@matthewvolk matthewvolk added this pull request to the merge queue Jan 8, 2026
Merged via the queue into canary with commit fcb946e Jan 8, 2026
9 checks passed
@matthewvolk matthewvolk deleted the CATALYST-1605-respect-store-pw-complexity-settings branch January 8, 2026 22:29
jamesqquick pushed a commit that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants