1.1.1 • Published 4 years ago

validation-helpers v1.1.1

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

Validation-helpers

Validation helpers makes you validate your body of request or any value you want with a simple set of rules with the help of Validator and other simple packages.

Usage

const { errors, isValid } = validationHelpers(value, rules);

rules need to be like

new Builder().required().isMember(["foo", "bla", "hi"]).value;

Example

const { errors, isValid } =
        validationHelpers('hello',
              new Builder()
              .required()
              .isMember(['foo', 'bla', 'hi'],'Not a valid member')
              .value;
);

This will throw an error for isMember rule with a simple message 'Not a valid member'.

Or the old way rules can be written with array of objects.

[
  { type: Rules.REQUIRED },
  { type: Rules.IS_MEMBER, array: ["foo", "bla", "hi"] }
];

type must be a valid type from validationHelpers.Types every type may have a second property must be passed like

{ type: Rules.IS_MEMBER, array: ['foo', 'bla', 'hi']

TODO

  1. Write readable usage example.
  2. Write Unit test for all cases.
  3. Integrate with CI.
1.1.1

4 years ago

1.1.0

4 years ago

0.4.0

5 years ago

1.0.4-beta

5 years ago

1.0.3-beta

5 years ago

1.0.2-beta

5 years ago

1.0.1-beta

5 years ago

1.0.0-beta

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago