npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cressida

v0.4.4

Published

validation messages done simply.

Readme

Cressida Build Status npm version tag npm Code Climate

Validation messages done simply.

Sole purpose of this library is to generate validation error messages to provide application wide consistency. The perfect use could be automatic message generation as Uranus does.

Installation

 $ npm install --save cressida

Tests

 # clone this repository & change directory
 $ git clone https://github.com/umayr/cressida && cd $_
 
 # install dependencies
 $ npm install
 
 # run tests
 $ npm test

API

 var Message = require('cressida').create();
 
 Message('foo', '!empty') // foo should not be empty.
 Message('len', [10, 20]) // should be between 10 to 20 characters.

Cressida supports numerous operators such as:

 'contains', // string contains a substring
 'alphanumeric', // string is alphanumeric
 'equals', // string equals to another string
 'alpha', // string consists for only letters
 'numeric', // string consists for only numbers
 'len', // string is between given length
 'length', // alias for `len`
 'lowercase', // string is lowercase
 'uppercase', // string is uppercase
 'null', // string is null
 'json', // string is json
 'email', // value is email
 'url', // value is url
 'ip', // value is ip address
 'uuid', // value is valid uuid
 'matches', // value matches the regex
 'array', // value is an array
 'creditcard', // value is a credit card number
 'int', // value is an integer
 'float', // value is a float number
 'decimal', // value is decimal number
 'hexadecimal', // value is hexadecimal number
 'hexcolor', // value is hex color code
 'date', // value is valid date
 'boolean', // value is either this or that
 'in', // value is in provided array
 'before', // date is before than provided date
 'after', // date is after than provided date
 'greater', // number is greater than provided value
 'smaller', // number is smaller than provided value
 'min', // number limit is minimum this
 'max' // number limit is maximum this
 'divisible' // number is divisible by this

Every operator can be either positive or negative using !, is and/or not prefixes.

 Message('foo', 'empty') // foo should be empty.
 Message('foo', '!empty') // foo should not be empty.
 Message('foo', 'isEmpty') // foo should be empty.
 Message('foo', '!isEmpty') // foo should not be empty.
 Message('foo', 'notEmpty') // foo should not be empty.
 Message('foo', '!notEmpty') // foo should be empty.
 Message('foo', 'isNotEmpty') // foo should not be empty.
 Message('foo', '!isNotEmpty') // foo should be empty.

Options

Cressida supports to change auxiliary verb in the message that is should by default.

 var Message = require('cressida').create({ auxiliary : 'must' });
 
 Message('foo', '!empty') // foo must not be empty.

It also supports to omit names from the messages.

 var Message = require('cressida').create({ includeName: false });
 
 Message('foo', '!empty') // should not be empty.

Examples

 Message('birth date', 'before', '09/05/2014'); // birth date should be before than 9th September 2014.
 Message('first name', 'length', [10, 20]); // first name should be between 10 to 20 characters.
 Message('username', 'alphanumeric'); // username should be consist of only letters & numbers.
 Message('age', 'min', 13); // age should be minimum 13.
 Message('birth date', 'date'); // birth date should be a valid date.
 Message('gender', 'boolean', ['male', 'female']); // gender should be either male or female.
 Message('fruit', 'in', ['apple', 'orange']); // fruit should be either apple or orange.
 Message('selected number', 'in', [1, 2, 3, 4, 5, 6]); // selected number should be one of these values (1, 2, 3, 4, 5, 6).

Contribute

If there is any idea, feedback, issue you may consider worth mentioning, please feel free to open an issue or send a pull request.

Lisence

The MIT License (MIT)

Copyright (c) 2015 Umayr Shahid <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.