zafiro-validators
Decorator based interface for Joi.
⚠️ This library is part of the Zafiro ecosystem but it is standalone and can be used on its own.
Installation
npm install zafiro-validators reflect-metadata
The basics
; ; ;expectresult1.error.to.eqlnull; ; ;expectresult2.error.message.to.eql `child "password" fails because ["password" with value "secret$" ` + `fails to match the required pattern: /^[a-zA-Z0-9]{3,30}$/]`; ; ;expectresult3.error.message.to.eql `child "email" fails because ["email" must be a valid email]`;
You can also invoke validate
for object literals but you will need to pass the expected schema as validate(literal, Class)
:
; ;expectresult2.error.message.to.eql `child "password" fails because ["password" with value "secret$" ` + `fails to match the required pattern: /^[a-zA-Z0-9]{3,30}$/]`;
You can learn more about the Joi API here.