adopted-ember-addons / adopted-ember-addons/ember-cp-validations

Validations are not showing on validate action

未關閉
#669 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
439
分支
172
PR 合併指標
30 天內沒有已合併 PR

描述

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', ...
```
```

{{validated-input model=this valuePath='name' placeholder='name'}}
{{validated-input model=this valuePath='email' placeholder='Email'}}

```

**UPDATE**:

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

```

{{validated-input model=this valuePath='name' placeholder='name' didValidate=didValidate}}
{{validated-input model=this valuePath='email' placeholder='Email' didValidate=didValidate}}

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。