Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support display of belongs-to validation messages #15

Open
fran-worley opened this issue Feb 12, 2018 · 0 comments
Open

Support display of belongs-to validation messages #15

fran-worley opened this issue Feb 12, 2018 · 0 comments

Comments

@fran-worley
Copy link

In the interests of sharing. The following setupValidations() method works to enable you to render nested form property validations (I'm sure some js ninjas out there can cleanup the string manipulation)!

\\file: app/components/bs-form/element.js
setupValidations() {
  let propertyPath = get(this, 'property');
  let modelPath = "model";
  let propertyArray = propertyPath.split('.');

  if (propertyArray.length > 1) {
    propertyPath = propertyArray.pop();
    modelPath = `model.${propertyArray.join('.')}`
  }

  defineProperty(this, '_attrValidations', readOnly(`${modelPath}.validations.attrs.${propertyPath}`)); 
  defineProperty(this, 'errors', readOnly('_attrValidations.messages'));
  defineProperty(this, 'warnings', readOnly('_attrValidations.warningMessages'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant