# User Registration Template

User sign-up and registration form.

## Files

- **user_registration_form.toml** - Modern registration form
- **registration_form.toml** - Alternative registration template

## Form Sections

### Account Setup
- Email address (with validation)
- Password (with strength indicator)
- Password confirmation
- Username (optional)

### Personal Information
- Full name
- Age/Date of birth
- Phone number

### Preferences
- Newsletter subscription
- Marketing communications
- Privacy notifications

### Terms & Conditions
- Terms of service agreement
- Privacy policy acceptance
- Marketing opt-in (optional)

## Running the Form

### CLI
```bash
cargo run --example user_registration_form
```text

### TUI
```bash
cargo run -p typedialog-tui -- \
  --config examples/09-templates/user_registration/user_registration_form.toml
```text

### Web (Recommended)
```bash
cargo run -p typedialog-web -- \
  --config examples/09-templates/user_registration/user_registration_form.toml
```text

Open browser to `http://localhost:3000`

## Expected Output

```json
{
  "email": "user@example.com",
  "password": "hashedpassword",
  "full_name": "Jane Doe",
  "date_of_birth": "1990-05-15",
  "phone": "+1-555-0123",
  "newsletter_subscribed": true,
  "terms_agreed": true,
  "privacy_agreed": true
}
```text

## Validation Rules

- **Email** - Must be valid and unique
- **Password** - Min 8 chars, uppercase, number, special char
- **Phone** - Valid phone format
- **Age** - Must be 18+ (if applicable)
- **Terms** - Must be checked

## Customization

### Add Fields
```toml
[fields.referral_code]
type = "text"
label = "Referral Code (Optional)"
required = false
validation = { pattern = "^[A-Z0-9]{6,}$" }
```text

### Add Email Verification
```toml
[fields.email_verify]
type = "email"
label = "Confirm Email"
validation = { must_match = "email" }
```text

### Password Strength Indicator
```toml
[fields.password]
type = "password"
label = "Password"
help = "Min 8 chars, uppercase, number, special char"
validation = {
  min_length = 8,
  require_uppercase = true,
  require_number = true,
  require_special = true
}
```text

## Integration

Post-submission workflow:
1. Create user account
2. Hash and store password
3. Send verification email
4. Store preferences
5. Trigger welcome email
6. Create user profile
7. Initialize user settings

## Security Considerations

- Passwords over HTTPS only
- Rate limit registration (prevent abuse)
- Verify email before full access
- CAPTCHA for bot prevention
- Log registration attempts
- Password hashing (bcrypt/argon2)
