@snsw-public/dvs-validation

4.2.0 • Public • Published

User guide for DVS validation

Steps to use this package are:

  1. Import the package as a dependency by running: npm install @snsw/dvs-validation
  2. Import the package helper objects (dvsDocType, dvsField, dvsValidations) and validation function (validateDvsField) to use in your code:
import {validateDvsField, dvsDocType, dvsField, dvsValidations} from 'dvs-validation';

//Optional step: You can override the default message for specific validations if they are not suitable
var validationMessages = dvsValidations;
validationMessages.MEDICARE.CARD_NUMBER.MEDICARE_NUMBER = 'Card number format is not valid';

var result = validateDvsField(dvsDocType.MEDICARE, dvsField.MEDICARE.CARD_NUMBER, "abcde", validationMessages);

//result will return:
//{
//  success: false,
//  error: {
//    code: MEDICARE-CARD_NUMBER-MEDICARE_NUMBER,
//    text: 'Card number format is not valid'
//  }     
//}

IMPORTANT: For Birth Certificate, Change of Name and Marriage Certificate, an extra parameter 'otherFields' is necessary. This is because these have conditionally mandatory fields that depend on the values of other fields. IMPORTANT: All the name length are limited to 100, Make sure if you are using this package to truncate the name in the backend according to DVS documentation. E.g.

import {validateDvsField, dvsDocType, dvsField, dvsValidations} from 'dvs-validation';
//this contains all the fields for this doc type on the screen
var otherFields = [];
otherFields[dvsField.BIRTH_CERT.STATE] = "NSW";
otherFields[dvsField.BIRTH_CERT.GIVEN_NAMES] = "Tom";
otherFields[dvsField.BIRTH_CERT.FAMILY_NAME] = "Lee";
otherFields[dvsField.BIRTH_CERT.BIRTH_DATE] = "11-11-2000"
otherFields[dvsField.BIRTH_CERT.REGISTRATION_NUMBER] = "";
otherFields[dvsField.BIRTH_CERT.CERTIFICATE_NUMBER] = "";

var result = validateDvsField(dvsDocType.BIRTH_CERT, dvsField.BIRTH_CERT.REGISTRATION_NUMBER, "", {}, otherFields);

//result will return:
//{
//  success: false,
//  error: {
//    code: BIRTH_CERT-REGISTRATION_NUMBER_NSW_VIC-REQUIRED,
//    text: 'Either a Registration Number or Certificate Number is required.'
//  }     
//}

Version history / changelog

  • 4.2.0 build the missing changes from v4.1.19/4.1.20/4.1.21
  • 4.1.21 Code clean up
  • 4.1.20 add validation MIN_LENGTH to medicare card number
  • 4.1.19 add validation MIN_LENGTH to medicare card number
  • 4.1.18 make licence number max length generic for all states
  • 4.1.17 Updating maximum length for TAS card number and adding new test cases
  • 4.1.16 remove registration year for birth certificate as it's not required anymore
  • 4.1.15 Show error message for Birth certificate based on registration state selected
  • 4.1.14 Add Photo Card Validaton
  • 4.1.13 upgrade dependencies
  • 4.1.12 Make the Licence Card Number field mandatory for VIC
  • 4.1.11 Make the Licence Card Number field mandatory for QLD
  • 4.1.10 Update error messages for DL , BC and CC
  • 4.1.9 update validation for ASIC/MSIC
  • 4.1.8 Limit the name length 128 for ASIC/MSIC
  • 4.1.7 Update Death certificate
  • 4.1.6 Add Death certificate
  • 4.1.5 Make the Licence Card Number field mandatory for All the state except VIC and QLD
  • 4.1.4 Make the Licence Card Number field mandatory for NSW
  • 4.1.2 Add Aviation and Maritime security identification cards
  • 4.1.1 Add the card number field to the driver licence document
  • 4.1.0 Update the rules for the Birth Certificate and Marriage Certificate, Make Certificate Number a mandatory field when the birth date or event date is after the date where certificate number is printed on those documents
  • 4.0.3 Update the rules for the Birth Certificate, Registration Number and Registration Date become mandatory for required state, Certificate Number become optional
  • 4.0.1 moved package to new scope/org
  • 3.0.20 add DOB validation for people over 120 years (applied for passport)
  • 3.0.18 update all name field maxLength to 100 to cater for customer who has long names
  • 3.0.16 fixing registration date for birth cert validation
  • 3.0.11 fixing registration date for marriage cert validation
  • 3.0.6 adding cetrelink DVA card validation
  • 3.0.5 adding cetrelink card validation
  • 3.0.3 change within range validation function to not use regex
  • 3.0.2 add IRN validation to be within the range 1-9 inclusive
  • 3.0.1 remove no multiple spaces between names
  • 3.0.0 Change date format to use hyphen instead of slash i.e. dd-MM-yyyy, MM-yyyy. Updated the validation messages for this format.
  • 2.0.0 Publish to public npm
  • 1.0.13 Bug fix for birth certificate TAS
  • 1.0.12 Add marriage certificate
  • 1.0.11 Add change of name certificate
  • 1.0.10 Add birth certificate
  • 1.0.9 Add citizenship acquisition date format fix
  • 1.0.8 Add immicard number fix
  • 1.0.7 Add passport given name fix
  • 1.0.6 Add immicard given name fix
  • 1.0.5 Add Citizenship/Registration By Descent validations, add immicard validations, add passport validations
  • 1.0.4 Bug fix
  • 1.0.2 Add driver licence validations and remove first, middle and last names from medicare
  • 1.0.1 Replace moment with luxon (for smaller date validation library size)
  • 1.0.0 Medicare initial implementation

Readme

Keywords

Package Sidebar

Install

npm i @snsw-public/dvs-validation

Weekly Downloads

4

Version

4.2.0

License

ISC

Unpacked Size

90.4 kB

Total Files

35

Last publish

Collaborators

  • service-ss
  • service-vm
  • service-ea