Upgrading from 3.x

Follow this guide, if you have been using Indicative 3.x. It highlights the breaking changes and major modifications to the API.

Table of Contents

Rules

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 )

Modifications

Following rules behaves differently from the older versions.

creditCard

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.

stripTags

The stripTags sanitization rule now accepts an array of whitelisted tags. Read more

email

Email validation also relies on validator.js and no longer validates the TLD (top level domain) length.

Modes

The concept of modes has been removed from Indicative and you are supposed to make use of configure method for that.

Removed
indicative.setMode('strict')
Instead use
const { configure } = require('indicative')

configure({
  EXISTY_STRICT: true
})

Formatters

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.

Earlier
const { validate, formatters } = require('indicative')

// default
formatters.default('jsonapi')

// for individual validation
indicative.validate(data, rules, messages, 'jsonapi')
Now
const { formatters, validate, configure } = require('indicative')

// default
configure({
  FORMATTER: formatters.JsonApi
})

// for individual validation
validate(data, rules, messages, formatters.JsonApi)