3.0.20 • Published 3 years ago
@snsw/dvs-validation v3.0.20
User guide for DVS validation
Steps to use this package are:
- Import the package as a dependency by running:
npm install @snsw/dvs-validation
- 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
- 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
3.0.20
3 years ago
3.0.18
3 years ago
3.0.19
3 years ago
3.0.16
3 years ago
3.0.17
3 years ago
3.0.14
3 years ago
3.0.15
3 years ago
3.0.12
4 years ago
3.0.11
4 years ago
3.0.10
4 years ago
3.0.9
4 years ago
3.0.8
4 years ago
3.0.7
4 years ago
3.0.6
4 years ago
3.0.4
4 years ago
3.0.5
4 years ago
3.0.3
5 years ago
3.0.2
5 years ago
3.0.1
5 years ago
3.0.0
5 years ago
2.0.0
5 years ago
1.0.13
5 years ago