adopted-ember-addons / adopted-ember-addons/ember-cp-validations
Check if a validator is disabled
- Linguagem predominante
- JavaScript
- Estrelas
- 439
- Forks
- 172
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
I have a model, with a description field, which is some time is required.
**model.js**
``` javascript
description: validator('presence', {
presence: true,
disabled(model) {
return this.get('model.simple')
}
}),
```
In my {{form-group}} component the label has a class, if the field is required. (It depends on if the model has a validation on the property)
**components/form-group.js**
```JS
init() {
this._super(...arguments);
var valuePath = this.get('property');
defineProperty(this, 'required', computed.oneWay(`model.validations.attrs.${valuePath}`));
},
hasValidationClass: computed('required', function(){
return this.get('required') ? 'has-error' : '';
}),
```
**components/form-group.hbs**
```HBS
{{#if label}}
{{label}}
{{/if}}
```
Is there a way to find out if the validator is disabled or not, so I could do something like this?
**components/form-group.js**
```JS
hasValidationClass: computed('required', function(){
return this.get('required') && !this.get('required.disabled') ? 'has-error' : '';
}),
```
Guia de contribuição
Direção de pesquisa
Start by tracing the validation metadata used by model.js and components/form-group.js, especially model.validations.attrs and the validator('presence', ...) configuration. Check how disabled(model) is evaluated and exposed, then verify that the form-group can distinguish an active required validator from a disabled one without changing unrelated validation behavior.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- frontend
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100