yahoo/jafar

Add validator - "typeof"

Ouverte

#31 ouverte le 20 févr. 2020

 (0 commentaire) (0 réaction) (0 personne assignée)JavaScript (9 forks)auto 404
enhancementgood first issuehelp wanted

Métriques du dépôt

Stars
 (109 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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

Guide contributeur