npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@snsw-public/dvs-validation

v4.2.2

Published

Utilities to validate the DVS data

Downloads

66

Readme

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.2 Change nsw birth certificate to allow 7 character registration number
  • 4.2.1 Change nsw birth certificate to allow 7 character registratio number
  • 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