1.0.2 • Published 5 years ago

objectid-validator v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

objectid-validator

FindById method in mongoose will give errors if object id is not in correct format. This module help to validate object id to avoid errors. It works as a middleware like bodymen.

Installation

npm install objectid-validator

Usage

import { idValidate, idValidateInParam } from "objectid-validator";

router.post("/create/", idValidate({ id: { required: true } }), create);
// This will return Network status code 400 with error messages if "id" in "req.body" is not valid

router.get(
  "/getData/:id",
  token({ required: true }),
  idValidateInParam("id"),
  getData
);
// This will return Network status code 400 with error messages if "id" in "req.params" is not valid

router.get(
  "/getData/:id",
  token({ required: true }),
  idValidateInParam("id", ["me"]),
  getData
);
// This will return Network status code 400 with error messages if "id" in "req.params" is not valid
// And it will not validate "id" if we passed string "me" instead of an ObjectId
1.15.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.14.0

1 year ago

1.13.0

1 year ago

1.12.0

1 year ago

1.19.0

1 year ago

1.18.0

1 year ago

1.17.0

1 year ago

1.16.0

1 year ago

1.9.0

1 year ago

1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.0.0-beta-9

1 year ago

1.0.0-beta-8

1 year ago

1.20.0

1 year ago

1.25.0

1 year ago

1.24.0

1 year ago

1.0.0-beta-13

1 year ago

1.0.0-beta-10

1 year ago

1.0.0-beta-11

1 year ago

1.51.0

1 year ago

1.11.0

1 year ago

1.10.0

1 year ago

1.0.0-beta-14

1 year ago

1.31.0

1 year ago

1.0.2

5 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago