Skip to content

docs: Create country implementation template #40

Description

@AngusHsu

Description

Create a template/guide for adding new country validators.

Parent Epic

#10 - Add CONTRIBUTING.md guide

Template Contents

Directory Structure

```
src/countries/[code]/
├── index.ts # Main export
├── national-id.ts # National ID validator
├── tax-id.ts # Tax ID validator (if applicable)
└── README.md # Country-specific docs
```

Validator Class Template

```typescript
export class NationalId {
static readonly PATTERN = /^...$/;

static validate(id: string): boolean {
// 1. Normalize input
// 2. Check pattern
// 3. Validate checksum
// 4. Validate date (if applicable)
return true;
}

static parse(id: string): ParsedInfo | null {
// Extract and return ID components
}
}
```

Checklist for New Countries

  • Research official ID format
  • Create validator class
  • Implement validate() method
  • Implement parse() method
  • Add to main dispatcher
  • Add to getCountryIdFormat()
  • Write tests (80%+ coverage)
  • Document format

Acceptance Criteria

  • Template file created
  • Checklist documented
  • Example implementation provided

Labels

documentation, template

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions