Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
/ stigma Public archive

📦 Declarative JavaScript and TypeScript schema validation tool that helps to keep your data healthy.

License

Notifications You must be signed in to change notification settings

hinell/stigma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STIGMA

Travis

START | USAGE | API | EXAMPLES | AUTHOR | CONTRIBUTE | LICENSE | SUPPORT

Declarative JavaScript and TypeScript js object schema validation tool.

try {
  new Rules({
      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';
  let schema        = {description: String }
  let dataStructure = {description: 'Description of most powerful library ever....'};
  try { new Rules(schema).validate(dataStructure,true); } 
  catch (){/* do something with error */}

or

new Rules(...).validate(dataStructure)
  .then(dataStructure => ...)
  .catch(error => /* do something with error * )

API

Full API description can be found here.

AUTHOR

You can follow me on twitter or just email me.

CONTRIBUTION & LICENSE

Check out (if any) contribution guide or license for more details.

PRODUCTION STATUS & SUPPORT

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.


Go back to the project description

About

📦 Declarative JavaScript and TypeScript schema validation tool that helps to keep your data healthy.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published