0.7.0 • Published 7 years ago

speculaas v0.7.0

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

Build Status Quality Gate Coverage Status Known Vulnerabilities npm version Join the chat at https://gitter.im/speculaas/Lobby

Speculaas

NodeJS version of clojure.spec

Installation

npm install speculaas

Example

const s = require('speculaas');
const {isString} = s.utils;

const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/

s.def('emailType', s.and(isString, s => emailRegex.test(s)));
        
s.def('first-name', isString);
s.def('last-name', isString);
s.def('email', 'emailType');
s.def('phone', isString);

// First name, last name and email are required. Phone number is optional
s.def('person', s.keys({req: ['first-name', 'last-name', 'email'], opt: ['phone']}));

s.isValid('::person',
{
    'first-name': 'Elon',
    'last-name': 'Musk',
    'email': 'elon@example.com'
});
// true

Usage

Documentation is in progress.

Tests

Unit tests:

npm test

Test coverage:

npm run cover

Run ESlint:

npm run lint

FAQ

Q: what kind of a silly name is speculaas?

A: nodespec and node-spec were already taken. Speculaas is a kind of a Dutch/Belgium biscuit.

Q: any alternatives for your code?

A: for an alternative look at js.spec

Contributing

If you want to contribute, you are more than welcome!

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago