# nope-validator

> Fast and simple JS validator

Latest version **1.2.2** (published 2026-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install nope-validator
pnpm add nope-validator
yarn add nope-validator
bun add nope-validator
```

## Health

**Score 50/100 (C)** — status: active.

Positive: no vulnerabilities; high maintenance score.

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

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2026-06-12 |
| First published | 2019-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 344 |
| Author | Bruno Vego |
| Maintainers | ftonato, bvego |
| Keywords | nope, js, object, validation, validator, scheme |

## Links

- npm: https://www.npmjs.com/package/nope-validator
- Repository: https://github.com/ftonato/nope-validator
- Homepage: https://github.com/ftonato/nope-validator#readme
- Issues: https://github.com/ftonato/nope-validator/issues
- npm.io page: https://npm.io/package/nope-validator

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.2 (latest) — 2026-06-12
- 1.0.0-beta.0 (beta) — 2021-05-05
- 1.2.0 — 2026-06-12
- 1.1.1 — 2026-04-16
- 1.1.0 — 2026-01-21
- 1.0.4 — 2022-05-29
- 1.0.3 — 2022-05-27
- 1.0.2 — 2021-06-01
- 1.0.1 — 2021-06-01
- 1.0.0 — 2021-05-05
- 0.12.3-beta.1 — 2021-05-05
- 0.12.3-beta.0 — 2021-05-04
- 0.12.2 — 2021-04-12
- 0.12.1 — 2021-04-09
- 0.12.0 — 2021-04-09
- … 20 more at https://npm.io/package/nope-validator/versions

## README

# Nope 🙅

[![Version](https://img.shields.io/npm/v/nope-validator.svg)](https://npm.im/nope-validator)
[![Bundle Size](https://img.shields.io/bundlephobia/min/nope-validator.svg)](https://bundlephobia.com/result?p=nope-validator)
[![Gzip Size](https://img.shields.io/bundlephobia/minzip/nope-validator.svg)](https://bundlephobia.com/result?p=nope-validator)
[![License](https://img.shields.io/npm/l/nope-validator.svg)](LICENSE)

> A lightweight, fast, and synchronous JavaScript validation library. Built for developers who need performance without the bloat.

---

## Why Nope?

**Nope** is a minimal validation library that prioritizes speed and simplicity. Inspired by [Yup](https://github.com/jquense/yup), Nope provides a familiar API while being significantly smaller and **~17x faster** than Yup by focusing exclusively on synchronous validation—which covers the vast majority of use cases.

> See [benchmark results](./benchmark/results.md) for detailed performance metrics and test specifications.

### Key Features

- ⚡ **Fast** - Optimized for performance with synchronous validation
- 📦 **Small** - Minimal bundle size, maximum efficiency
- 🎯 **Simple** - Clean, intuitive API that's easy to learn
- 🔒 **Type Safe** - Full TypeScript support out of the box
- 🚫 **No Exceptions** - Returns error objects instead of throwing errors
- 🔌 **Framework Ready** - Works seamlessly with React Hook Form and Formik

### How It Works

Unlike traditional validators that throw errors, Nope returns error objects. If validation passes, it returns `undefined`. This approach is more predictable and easier to work with in modern JavaScript applications.

---

## Installation

```bash
npm install nope-validator
# or use your preferred package manager (pnpm, yarn, bun, etc)
```

---

## Quick Start

```js
import Nope from 'nope-validator';

// Define your validation schema
const UserSchema = Nope.object().shape({
  name: Nope.string()
    .atLeast(5, 'Please provide a longer name')
    .atMost(255, 'Name is too long!'),
  email: Nope.string().email().required(),
  confirmEmail: Nope.string()
    .oneOf([Nope.ref('email')], 'Emails must match')
    .required(),
});

// Validate data
const errors = UserSchema.validate({
  name: 'John',
  email: 'me@gmail.com',
  confirmEmail: 'me@gmail.com',
});
// Returns: { name: 'Please provide a longer name' }

const valid = UserSchema.validate({
  name: 'Jonathan Livingston',
  email: 'me@gmail.com',
  confirmEmail: 'me@gmail.com',
});
// Returns: undefined (no errors)
```

---

## Framework Integration

### React Hook Form

Nope works seamlessly with React Hook Form using the official resolver:

```jsx
import { nopeResolver } from '@hookform/resolvers/nope';
import { useForm } from 'react-hook-form';
import * as Nope from 'nope-validator';

const schema = Nope.object().shape({
  username: Nope.string().required('Username is required'),
  password: Nope.string().required('Password is required'),
});

function LoginForm({ onSubmit }) {
  const {
    register,
    formState: { errors },
    handleSubmit,
  } = useForm({
    resolver: nopeResolver(schema),
  });

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register('username')} />
      {errors.username && <div>{errors.username.message}</div>}

      <input type="password" {...register('password')} />
      {errors.password && <div>{errors.password.message}</div>}

      <button type="submit">Submit</button>
    </form>
  );
}
```

### Formik

Use Nope with Formik by passing the validation function to the `validate` prop:

```jsx
import { Formik, Form, Field, ErrorMessage } from 'formik';
import * as Nope from 'nope-validator';

const schema = Nope.object().shape({
  username: Nope.string().required('Username is required'),
  password: Nope.string().required('Password is required'),
});

function LoginForm() {
  return (
    <Formik
      initialValues={{ username: '', password: '' }}
      validate={(values) => schema.validate(values)}
      onSubmit={(values) => console.log('Submitted', values)}
    >
      <Form>
        <Field type="text" name="username" />
        <ErrorMessage name="username" component="div" />

        <Field type="password" name="password" />
        <ErrorMessage name="password" component="div" />

        <button type="submit">Submit</button>
      </Form>
    </Formik>
  );
}
```

---

## Documentation

For complete API documentation, examples, and advanced usage, visit the [documentation wiki](https://github.com/ftonato/nope-validator/wiki).

---

## Contributing

We welcome contributions! Please see our [Contributing Guide](https://github.com/ftonato/nope-validator/blob/master/CONTRIBUTING.md) for details on how to get started.

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