yahoo/jafar

Add validator - "typeof"

オープン

#31 opened on 2020/02/20

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (9 件のフォーク)auto 404
enhancementgood first issuehelp wanted

Repository metrics

Stars
 (109 個のスター)
PR merge metrics
 (30d に merged 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

コントリビューターガイド