设置ember-cp验证

时间:2016-06-20 20:23:15

标签: validation ember.js ember-data ember-validations

我试图将ember-cp-validations集成到我的项目中,到目前为止,代码运行k但是当我尝试运行"验证"方法我收到此错误

  

未捕获的TypeError:Validator.getDependentsFor不是函数

我将错误追踪到此行

https://github.com/offirgolan/ember-cp-validations/blob/v2.9.3/addon/validations/factory.js#L436

const dependents = Validator.getDependentsFor(attribute, options) || [];

尝试在此处返回的Validator对象上调用函数getDependentsFor

https://github.com/offirgolan/ember-cp-validations/blob/v2.9.3/addon/validations/factory.js#L434

const Validator = type === 'function' ? BaseValidator : lookupValidator(owner, type);

因为类型等于"存在"它使用lookupValidator查找验证器并找到它,但返回的类没有函数getDependentsFor,我不确定这是一个错误还是我'我遗漏了一些东西:/

版本 恩伯:2.5.1 Ember数据:2.6.1 ember-cp-validations:2.9.3

    import { validator, buildValidations } from 'ember-cp-validations';

    const Validations = buildValidations({
      email: [
        validator('presence', true),
        validator('format', { type: 'email', allowBlank: true })
      ]
    });

    var User;

    User = DS.Model.extend(Validations, {
      ...
    })

任何帮助将不胜感激!

提前致谢!!!

0 个答案:

没有答案