Skip to content

pavanmanideep/Singapore-Identity-Number-Validator-PCFControl

Repository files navigation

License Platform Type Release

Singapore NRIC/FIN Validator - PCF Control

A PowerApps Component Framework (PCF) control for validating Singapore NRIC/FIN (National Registration Identity Card) and FIN (Foreign Identification Number) numbers.

Features

  • ✅ Real-time validation of Singapore NRIC/FIN numbers
  • ✅ Format validation (prefix, digits, checksum letter)
  • ✅ Checksum algorithm verification
  • ✅ Auto-formatting (converts to uppercase, removes invalid characters)
  • ✅ Visual feedback with color-coded validation messages
  • ✅ Supports all NRIC/FIN types: S, T, F, G, M prefixes
  • ✅ Read-only mode support
  • ✅ 9-character maximum length enforcement

What is NRIC/FIN?

Singapore NRIC/FIN numbers are unique identification numbers issued to:

  • S prefix: Singapore Citizens (born before 2000)
  • T prefix: Singapore Citizens (born from 2000 onwards) and Permanent Residents
  • F prefix: Foreigners (issued before 2000)
  • G prefix: Foreigners (issued from 2000 onwards)
  • M prefix: Foreigners (issued from 2022 onwards)

Format: [Prefix][7 digits][Checksum Letter] (e.g., S1234567D)

Prerequisites

Before you begin, ensure you have the following installed:

Installation

o Download solution o Go to your Dynamics 365 CRM environment. o Navigate to Settings > Solutions. o Click Import and select the generated zip file. o Follow the prompts to complete the import process.

Project Structure

SingaporeNricValidator/
├── SingaporeNricValidator/     # PCF component source
│   ├── index.ts                # Main component logic
│   ├── ControlManifest.Input.xml  # Component manifest
│   └── generated/              # Auto-generated type definitions
├── EcellorsSingaporeNRICSolution/  # Solution wrapper for deployment
├── package.json                # NPM dependencies
├── tsconfig.json               # TypeScript configuration
└── eslint.config.mjs           # ESLint configuration

Usage in Power Apps

Making customizations to this control

  1. Clone the Repo

git clone https://github.com/pavanmanideep/Singapore-Identity-Number-Validator-PCFControl.git

  1. Build the solution

    npm run build
  2. Create a solution package (using Power Platform CLI)

    pac solution init --publisher-name YourPublisher --publisher-prefix prefix
    pac solution add-reference --path ./
    msbuild /t:build /restore
  3. Import to Power Apps

    • Navigate to Power Apps

    • Go to Solutions

    • Import the managed solution package available for this control

    • Open any entity form image Next image Create a single line text column, let's say we create Singapore NRIC/FIN image Bind this field to control, by attaching it to a component image

      image

Validation Messages

  • Valid NRIC/FIN: Green message "Valid NRIC/FIN."
  • Invalid Format: Red message "Please enter a valid Singapore NRIC Number"
  • Empty Field: Gray message "Enter NRIC/FIN."

How the Validation Works

The control implements the official Singapore NRIC/FIN checksum algorithm:

  1. Format Check: Verifies the format matches [STFGM][7 digits][Letter]

  2. Checksum Calculation:

    • Multiply each digit by weights: [2, 7, 6, 5, 4, 3, 2]
    • Add offset based on prefix (T/G: +4, M: +3)
    • Calculate remainder when divided by 11
    • Compare with expected checksum letter
  3. Checksum Letter Sequences:

    • S/T (Citizens): J, Z, I, H, G, F, E, D, C, B, A
    • F/G/M (Foreigners): X, W, U, T, R, Q, P, N, M, L, K

Testing

Try these sample valid NRIC numbers in the test harness:

  • S1234567D
  • T1234567J
  • F1234567N
  • G1234567X

Model Driven Apps image

image

If you were interested in using this control, there is a managed solution in the Repo, you can install this solution in your environment, clone this repo, built control at your convenience following

https://ecellorscrm.com/2023/02/23/run-pcf-code-components-in-browser-quick-recap/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

For issues, questions, or contributions, please use the GitHub issue tracker.


Note: This control validates the format and checksum of NRIC/FIN numbers but does not verify if the number is actually issued by the Singapore government. Always verify identity documents through official channels. Once the managed solution is imported to the target Power Platform Environment, you may loose the capability to delete the control, so please use at caution.

About

A PowerApps Component Framework (PCF) control for validating Singapore NRIC/FIN numbers with checksum verification, auto-formatting, and visual feedback.

Topics

Resources

License

Stars

Watchers

Forks

Contributors