Validations with EmberObject does not work?
ollar opened this issue · comments
Environment
- Ember Version: 4.6.0
- Ember CLI Version: 4.6.0
- Ember CP Validations Version: 4.0.0
Steps to Reproduce
I am trying to test the addon on a simple case:
import EmberObject from '@ember/object';
import { validator, buildValidations } from 'ember-cp-validations';
export const Validations = buildValidations({
name: validator('presence', true),
secondName: validator('presence', true),
password: validator('presence', true),
});
export default class FormValidation extends EmberObject.extend(Validations) {
name = '';
secondName = '';
password = '';
}
when I am using v-get in template:
{{v-get this.formModel 'name' 'message'}}
I get error
Uncaught Error: [ember-cp-validations] `lookupValidator` requires owner/container access.
Thanks!
How are you initializing your FormValidation
class?
You may need to inject the owner if you are manually creating creating an instance (documentation).
Something like:
import { getOwner } from '@ember/application';
...
FormValidation.create(
getOwner(this).ownerInjection(),
{
... // initial values
}
)
@ollar believe this can be closed now? The feedback from @kiwi-josh is accurate I believe
Thanks guys, seems that solves my question