# ember-validators

> A collection of EmberJS validators

Latest version **5.0.0** (published 2025-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-validators
pnpm add ember-validators
yarn add ember-validators
bun add ember-validators
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-04-21 |
| First published | 2016-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 104.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 23 |
| Author | Offir Golan |
| Maintainers | rwwagner90, knownasilya, offirgolan, snewcomer, sergeastapov |
| Keywords | ember-addon, validations, validators |

## Links

- npm: https://www.npmjs.com/package/ember-validators
- Repository: https://github.com/adopted-ember-addons/ember-validators
- Homepage: https://github.com/adopted-ember-addons/ember-validators#readme
- Issues: https://github.com/adopted-ember-addons/ember-validators/issues
- npm.io page: https://npm.io/package/ember-validators

## Dependencies (3)

- [@embroider/macros](https://npm.io/package/@embroider/macros.md) ^1.16.12
- [decorator-transforms](https://npm.io/package/decorator-transforms.md) ^2.2.2
- [@embroider/addon-shim](https://npm.io/package/@embroider/addon-shim.md) ^1.9.0

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2025-04-21
- 4.1.2 — 2022-02-09
- 4.1.1 — 2022-02-09
- 4.1.0 — 2022-01-26
- 4.0.1 — 2022-01-06
- 4.0.0 — 2021-07-04
- 3.0.1 — 2020-10-07
- 3.0.0 — 2020-10-07
- 2.0.0 — 2019-01-07
- 1.2.3 — 2019-01-07
- 1.2.2 — 2019-01-07
- 1.2.1 — 2018-10-05
- 1.2.0 — 2018-05-24
- 1.1.1 — 2018-02-12
- 1.1.0 — 2018-02-10
- … 9 more at https://npm.io/package/ember-validators/versions

## README

# Ember Validators

[![Build Status](https://github.com/adopted-ember-addons/ember-validators/actions/workflows/ci.yml/badge.svg)](https://github.com/adopted-ember-addons/ember-validators/actions/workflows/ci.yml)
[![npm version](https://badge.fury.io/js/ember-validators.svg)](http://badge.fury.io/js/ember-validators)

A collection of EmberJS validators

## Compatibility

- Ember.js v4.8 or above
- Embroider or ember-auto-import v2

## Installation

```shell
ember install ember-validators
```

## Helpful Links

- ### [Documentation](https://adopted-ember-addons.github.io/ember-validators)
- ### [Changelog](CHANGELOG.md)

## Looking for help?

If it is a bug [please open an issue on GitHub](http://github.com/adopted-ember-addons/ember-validators/issues).

## Usage

Validators can be individually imported and used as such

```js
import validatePresence from 'ember-validators/presence';
import validateLength from 'ember-validators/length';

validatePresence('foo', { presence: true });
validateLength('foo', { min: 1 });
```

or via the **validate** method provided

```js
import { validate } from 'ember-validators';

validate('presence', 'foo', { presence: true });
validate('length', 'foo', { min: 1 });
```

## Validator Method Signature

Each validator has the following signature:

```js
function (value, options, model, attribute) {}
```

#### Parameters:

- value (**Mixed**):

  The value to validate

- options (**Object**):

  A mutable object that holds validation specific options

- model (**Object**):

  The model that is being validated

- attribute (**String**):

  The attribute that is being validated

#### Returns:

- **Boolean**

  `true` will be returned if the validation passed

- **Object**

  Validation failed and a message should be built with the given attributes

  - type (**String**):

    The message type

  - value (**Mixed**):

    The value that was validated

  - context (**Object**):

    The error message context

  - message (**String**):

    The error message. If this is specified, use this string as the error message instead of building one.

## Contributing

See the [Contributing](CONTRIBUTING.md) guide for details.

## License

This project is licensed under the [MIT License](LICENSE.md).

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