Skip to content

Implement configurable PasswordIdentity schema factory #2

@dpickett

Description

@dpickett

Summary

Create a flexible schema factory that generates Zod schemas for password-based authentication with configurable identifier types.

Implementation

  • Support email, username, and phone as identifier options
  • Compile-time type safety with as const arrays
  • Custom validation schemas for each identifier type
  • Default validation: email format, phone E.164, username string

Usage

// Email only
const schema = createPasswordIdentitySchema(['email'] as const);

// Multiple identifiers with custom validation
const schema = createPasswordIdentitySchema(['email', 'phone'] as const, {
  phone: z.string().regex(/^\+1[0-9]{10}$/)
});

Related: User story 20250709_user-sign-up.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions