Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help required in understanding validation function #22

Open
WaseemAR opened this issue Dec 3, 2017 · 2 comments
Open

Help required in understanding validation function #22

WaseemAR opened this issue Dec 3, 2017 · 2 comments

Comments

@WaseemAR
Copy link

WaseemAR commented Dec 3, 2017

Hi,

I am using your Library for one of my project, Its a great library. i have been playing around the code for developing a async validations. I am stuck in a part of your code. I would be glad if u can help me understand. here is a snippet of the code where a little knowledge is required.```

    validations.presence = function presence(paramName, customMessage) {
      return function(params) {

        return {
          field: paramName,
          message: translator(customMessage || 'required', {paramName: paramName}, locals),
          result: get(params, paramName) != null
       }
     }
   }

I want to know how the params value is passed?

Thank you.

@nettofarah
Copy link
Owner

Hey, @WaseemAR.
In this case params maps directly to the original object you pass to validate*** or assert***.

Here's where the params are passed: https://github.com/nettofarah/property-validator/blob/master/lib/request_validator.js#L6-L8

@WaseemAR
Copy link
Author

Thank you @nettofarah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants