Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Add custom attribute label validator #313

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

sewil
Copy link

@sewil sewil commented Dec 19, 2019

Adds support for using attribute labels to be displayed in the error message instead of prettified attribute. This enables error message localisation. Usage:

const validationConstraints = {
  age: {
    attributeLabel: "The user age",
    presence: true,
    type: "string"
  }
};
Output: The user age is required

Changes:

  • attributeLabel validator is bypassed in validator check loop.
  • If errorInfo attributeLabel is set in convertErrorMessages, it will be prepended in place of prettified errorInfo attribute.

@coveralls
Copy link

coveralls commented Dec 19, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling bf246b6 on app-shack:master into c64df5d on ansman:master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants