ansman/validate.js

Validation constraint aliasing

Opened this issue · 1 comments

It would be great if validation constraint keys can be aliased, there are cases where the key used as a constraint shouldn't be shown in the error message as they are not user-friendly e.g. user.info.0. It should be possible to define aliases that can replace constraint name, e.g

const constraint = {
  'user.info.0': { presence: true }
}

// an alias object can be passed to the validator

const aliases = {'user.info.0': 'First Information'}

such that if there is a presence error in user.info.0 it would be displayed as First Information can't be blank

Also relevent to this issue #69