# form-part-validator

> The validator allows you to specify easily what each input should contain to be valid you can then watch for errors :

Latest version **1.0.2** (published 2023-01-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install form-part-validator
pnpm add form-part-validator
yarn add form-part-validator
bun add form-part-validator
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-01-23 |
| First published | 2023-01-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | smoqqqq |

## Links

- npm: https://www.npmjs.com/package/form-part-validator
- npm.io page: https://npm.io/package/form-part-validator

## Recent versions

- 1.0.2 (latest) — 2023-01-23
- 1.0.1 — 2023-01-11
- 1.0.0 — 2023-01-10

## README

# FORM PART VALIDATOR

The validator allows you to specify easily what each input should contain to be valid
you can then watch for errors :

```javascript
import Validator from "./validator.js";

const validator = new Validator();
validator.watch(document.querySelectorAll("input"));
```

you simply add a keyword to it's `data-form-constraints` attribute, separated by spaces :

```html
<input type="text" name="foo" data-form-constraints="length:0:38 nodot nowhitespace nonumber">
```

this will, when using the `watch` function, produce an error badge when the input doesn't match it's constraints

# CONSTRAINTS

| name              | function                                              | usage                     |
|-------------------|-------------------------------------------------------|---------------------------|
| length            | assert length between min and max                     | length:min:max            |
| minLength         | assert minimum length                                 | minLength:min             |
| maxLength         | assert maximum length                                 | maxLength:max             |
| text              | assert value contains some text                       | text                      |
| uppercase         | assert value is uppercase                             | uppercase                 |
| lowercase         | assert value is lowercase                             | lowercase                 |
| number            | assert value is numbers                               | number                    |
| nodot             | assert value has not dots                             | nodot                     |
| nowhitespace      | assert value whitspace                                | nowhitespace              |
| nonumber          | assert value contains no numbers                      | nonumber                  |
| email             | assert value looks like an email                      | email                     |
| dateInPast        | assert the date is x years:months:days in the past    | dateInPast:year:month:day |
| dateInFuture      | assert the date is x years:months:days in the future  | dateInPast:year:month:day |

## MUST HAVE
the `name` attribute is necessary for error messages to work properly

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