Code Monkey home page Code Monkey logo

stigma's Introduction

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

stigma's People

Contributors

hinell avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.