validator-with-rules

validating form using rules

Usage no npm install needed!

<script type="module">
  import validatorWithRules from 'https://cdn.skypack.dev/validator-with-rules';
</script>

README

validator-with-rules

validator-with-rules is a nodejs library for validating form.

Installation

Use the package manager to install validator-with-rules.

npm install foobar

Usage

import { validate } from "validator-with-rules";

const data = {
  email: "iqbal.pk@acodez.co.in",
  password: "********",
};

const rules = {
  email: {
    notNull: true,
    regex: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
  },
  password: {
    notNull: true,
    minLength: 4,
    maxLength: 10,
  },
  image: {
    notNull: false,
    maxSize: 500,
  },
};

let err = validate(data, rules);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT