You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 2, 2022. It is now read-only.
Declarative JavaScript and TypeScript js object schema validation tool.
try{newRules({name : [String,min(4)],password : [String,min(6)],email : [String,(string)=>/@/g.test(string)||'@ is missing!'],biography: ['optional',String,min(32),max(512)],birthDate: ['optional',Date],code : ['optional',Number]}).validate({name : 'Ragnarok',password: '12345qwerty',email : 'what?'},true);}catch(e){// throws Rule.INVALID_VALUE error with '@ is missing!' message}
ALTERNATIVES
Q: Why don't to use joi or any other schema-validation library instead?
A: Well the reason of this is that some of these libraries
are too complicated and time-expensive to learn for me.
The Stigma was created as ad-hoc solution and isn't intended
to be replacement for any of these useful librariess.
You are free to choose any.
GETTING STARTED
Before you start make sure you have NodeJS installed and available in your global PATH variable.
INSTALLATION
$ cd your/project/path
$ npm i -S hinell/stigma
USAGE
import{Rules}from'stigma';letschema={description: String}letdataStructure={description: 'Description of most powerful library ever....'};try{newRules(schema).validate(dataStructure,true);}catch(){/* do something with error */}
You should be aware that the library is not supported by anyone except me.
None gurantees bugless behaviour (though currenlty it is fully covered by tests).
If you want to become a patron of this project or offer me a support please follow here.