yahoo/jafar

Add validator - "typeof"

開放

#31 建立於 2020年2月20日

 (0 則留言) (0 個反應) (0 位負責人)JavaScript (9 個分叉)auto 404
enhancementgood first issuehelp wanted

倉庫指標

星標
 (109 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Add a new validator to packages/form/src/validators.js file of "typeof".

Motivation Fields can define a validation of their value type, to be verified when field value changes. For example to verify that the value of the field is "string".

Code

  • args (and defaultArgs) should include:
  • "type" - default undefined
  • func: checks if : typeof value === args.type

  • message: should have a matching error message depend on the args of 'Invalid type. Expected type of "{args.type}"'

Tests

Docs should add documentation in Form -> Validators -> Build in validators: https://yahoo.github.io/jafar/docs/validators.html#built-in-validators

CHANGELOG

貢獻者指南