2014-05-05 64 views
1

breezejs中允許空字符串在所需屬性中的首選方式是什麼?如何讓breezejs驗證器允許空字符串

我發現this answer其中建議更換這樣要求的驗證:

Validator.required = function (context) { 
    var valFn = function (v, ctx) { 
     return v != null; 
    } 
    return new Validator("required", valFn, context); 
}; 
// register the new validator so that metadata can find it. 
Validator.registerFactory(Validator.required, "required"); 

這裏也提到一個allowEmptyStrings標誌的地方。

這樣做的首選方法是什麼?

回答

1

您可以創建一個「必要」的驗證,允許空字符串是這樣的:

var v0 = Validator.required({ allowEmptyStrings: true }); 
+0

是更換必需的驗證工廠仍使全球空字符串的首選方法原來的技術? –

相關問題