dockwa / simple-react-validator

A simple react form validator inspired by Laravel validation.
https://dockwa.github.io/simple-react-validator
MIT License
276 stars 77 forks source link

Validation message shows field names in lowercase always! #467

Open rajat-arora084 opened 1 year ago

rajat-arora084 commented 1 year ago

When I try to show validation messages on a field. It shows the field name in lowercase. Can it be shown as per the field name?

Example: My field name is: Mobile Number

image
fxgit commented 1 year ago
class NewSimpleReactValidator extends SimpleReactValidator {
  constructor(options = {}) {
    super(options);

    this.helpers.humanizeFieldName = (field) => {
      // startCase is a Lodash method
      return _.startCase(field.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/_/g, ' '));
    }
  }
}