# validity-equal

> Validity style validator to ensure a property is equal to some primitive value

Latest version **0.1.3** (published 2013-12-13) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install validity-equal
pnpm add validity-equal
yarn add validity-equal
bun add validity-equal
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2013-12-13 |
| First published | 2013-12-13 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | bengourley |
| Keywords | validity, validation, number |

## Links

- npm: https://www.npmjs.com/package/validity-equal
- Repository: git@github.com:bengourley/validity-equal
- Issues: https://github.com/bengourley/validity-equal/issues
- npm.io page: https://npm.io/package/validity-equal

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2013-12-13
- 0.1.2 — 2013-12-13
- 0.1.1 — 2013-12-13
- 0.1.0 — 2013-12-13

## README

# validity-equal

[![Build Status](https://travis-ci.org/bengourley/validity-equal.png?branch=master)](https://travis-ci.org/bengourley/validity-equal)

Validity style validator to ensure a property is equal to some primitive value. This
might seem trivial, but it's useful when you are leveraging schemata for its validation
and error message for something like 'agreed to terms and conditions'.

## Installation

    npm install validity-equal

## Usage

Below is a simple example for usage with schemata:

```js

var validity = require('validity')
  , schemata = require('schemata')
  , createValidator = require('validity-equal')

var schema = schemata(
    { agreedToTerms:
      { type: Boolean
      , validators: { all: [ createValidator(true, 'Must agree to T&Cs') ] }
      }
    })

schema.validate({ agreedToTerms: true }, function (error, errorMessage) {
  console.log(errorMessage) //-> undefined
})

schema.validate({ agreedToTerms: false }, function (error, errorMessage) {
  console.log(errorMessage) //-> 'Must agree to T&Cs'
})
```

## API

### var validate = createValidator(Mixed: value, String: failureMessage)

Equality check is done with `===` so `value` must be primitive.

### validate(String:key, String:keyDisplayName, Object:object, Function:cb)

This is a [validity](https://npmjs.org/package/validity) compatible function, which in turn is
used by [schemata](https://npmjs.org/package/schemata) for schema validation.

The callback signature `cb(err, errorMessage)`.
- `err` is an `Error` object if something bad happened and `null` otherwise.
- `errorMessage` is a `String` if a validation error happened and `undefined` otherwise.

## Licence
Licensed under the [New BSD License](http://opensource.org/licenses/bsd-license.php)

---
_Source: https://npm.io/package/validity-equal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
