didi/cube-ui

[New Feature] Validate扩展方法和类型能不能增加链式调用

Open

#356 aperta il 26 nov 2018

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (1503 fork)batch import
help wanted

Metriche repository

Star
 (9088 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

What problem does this feature solve?

Validator添加自定义规则时候:

Validator.addRule('odd', (val, config, type) => !config || Number(val) % 2 === 1)
Validator.addMessage('odd', 'Please input odd.')

显得比较蛋疼,最好能链式调用

Validator.addRule('odd', (val, config, type) => !config || Number(val) % 2 === 1)
.addMessage('odd', 'Please input odd.')

显得比较优雅

Guida contributor