Follow this guide, if you have been using Indicative 3.x. It highlights the breaking changes and major modifications to the API.
Following sanitization rules have been removed from indicative and you can use lodash directly for them.
camelCase
capitalize
decapitalize
title
underscore
toDash
humanize
toFloat ( use parseFloat directly )
Following rules behaves differently from the older versions.
Indicative now uses validator.js isCreditCard function to validate the credit cards. Due to the same, fake credit cards like 4444-4444-4444-4444 will fail the validation.
Email validation also relies on validator.js and no longer validates the TLD (top level domain) length.
The concept of modes has been removed from Indicative and you are supposed to make use of configure method for that.
indicative.setMode('strict')
const { configure } = require('indicative')
configure({
EXISTY_STRICT: true
})
In previous version of Indicative, each formatter was given a name and can be referenced using name. From 4.0.0 formatters are supposed to be passed/used directly.
const { validate, formatters } = require('indicative')
// default
formatters.default('jsonapi')
// for individual validation
indicative.validate(data, rules, messages, 'jsonapi')
const { formatters, validate, configure } = require('indicative')
// default
configure({
FORMATTER: formatters.JsonApi
})
// for individual validation
validate(data, rules, messages, formatters.JsonApi)