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

Validations are not showing on validate action #669

Open
zion03 opened this issue Nov 14, 2019 · 0 comments
Open

Validations are not showing on validate action #669

zion03 opened this issue Nov 14, 2019 · 0 comments

Comments

@zion03
Copy link

zion03 commented Nov 14, 2019

DEBUG: Ember : 3.14.1
index.js:194 DEBUG: Ember Data : 3.13.1
index.js:194 DEBUG: jQuery : 3.4.1
index.js:194 DEBUG: Ember Bootstrap : 2.8.1
index.js:194 DEBUG: Ember Simple Auth : 2.1.0
"ember-cp-validations": "^4.0.0-beta.10",

Validator works as expected, but only when I click on specific field. So If I click submit button without fill any field - there no error notification (but validation return "false" - not valid). In the past versions this.set('didValidate', true); - solved this problem.

const Validations = buildValidations({
  name: {
    debounce: 500,
    validators: [
      validator('presence', true)
    ]
  },
  email: {
    debounce: 200,
    validators: [
      validator('presence', true),
      validator('ds-error'),
      validator('format', {
        type: 'email'
      })
    ]
  }
});

export default Component.extend(Validations,{
  store: service(),
  actions: {
    reg() {
      this.validate().then(({ model, validations }) => {
        if (!validations.get('isValid')){return; }
        let user = this.get('store').createRecord('user', ...
<form {{action 'reg' on='submit'}}>
 {{validated-input model=this valuePath='name' placeholder='name'}}
 {{validated-input model=this valuePath='email' placeholder='Email'}}
</form>

UPDATE:

So the problem was in validated-input.js, didValidate si not computed anymore. Add didValidate to each validated-input solve problem:

<form {{action 'reg' on='submit'}}>
 {{validated-input model=this valuePath='name' placeholder='name' didValidate=didValidate}}
 {{validated-input model=this valuePath='email' placeholder='Email' didValidate=didValidate}}
</form>

Is this solution is right way to show validations? Thanks!

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