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

What is "path" argument? #34

Open
PatrickLumenus opened this issue Jan 7, 2020 · 1 comment
Open

What is "path" argument? #34

PatrickLumenus opened this issue Jan 7, 2020 · 1 comment

Comments

@PatrickLumenus
Copy link

I just ran into this library, while looking for a library to do data sanitization for one of my apps. It looks very promising. I just have one question though. I noticed that each "as" function has a second "path" argument. What exactly is this argument? Or, what do I pass in to it? The docs in the README do not really go over the arguments.

Thanks.

@sz-piotr
Copy link
Contributor

sz-piotr commented Jan 7, 2020

Hey Patrick. Great question. The path argument is used for error reporting. The sanitizers call the nested ones recursively providing the current path so that in the end you can get an error saying expected string at "object.key[1]".

If you are wondering what to pass I would recommend going with "" - empty string. Before you do that though have a look at the cast function. You can use it to sanitize your values: e.g. cast(myValue, asString). Then you won't need to worry about the path argument.

Hope this helps

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