node-input-validator icon indicating copy to clipboard operation
node-input-validator copied to clipboard

Delete unspecified properties

Open omargho opened this issue 5 years ago • 9 comments

is it possible to delete properties that wasn't included into validations rules from the validated object ?

omargho avatar Sep 11 '20 20:09 omargho

didn't get your point. you need to elaborate, what you are trying to achieve?

bitnbytesio avatar Sep 15 '20 18:09 bitnbytesio

for example if we have an endpoint that takes id as parameter and we setup the validation for this parameter. when we receive a request with id,name we delete name parameter because it wasn't specified on the validation rules

omargho avatar Sep 15 '20 19:09 omargho

@bitnbytesio please let me now if you need further explanation, and if it's expected to be added to the library, i can create a PR for this if it's ok

omargho avatar Sep 26 '20 16:09 omargho

Sorry for they late reply, I was too busy with other stuff. PR always WELCOMED. Please explain your situation on https://jsfiddle.net/ or some other platform of that kind.

bitnbytesio avatar Dec 09 '20 08:12 bitnbytesio

Inputs:

{ name: 'Some Name', email: "[email protected]", __v: 24, }

Rules:

{ name: 'required|string', email: 'required|string', }

You want this library to get rid of __v property as it is not declared in validation rules

Expected Output:

{ name: 'Some Name', email: "[email protected]", }

bitnbytesio avatar Dec 09 '20 08:12 bitnbytesio

yes that's it

omargho avatar Dec 11 '20 02:12 omargho

Has this been included?

dylangolow avatar Aug 11 '21 03:08 dylangolow

+1

lsfratel avatar Jun 28 '22 01:06 lsfratel

release under beta v5.0.0-beta.7

bitnbytesio avatar Dec 02 '22 12:12 bitnbytesio