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

Asychronous type validation / coercion #53

Open
Pampattitude opened this issue Mar 19, 2015 · 0 comments
Open

Asychronous type validation / coercion #53

Pampattitude opened this issue Mar 19, 2015 · 0 comments

Comments

@Pampattitude
Copy link

Hi,

I am currently using jjv for parsing user-provided JSON from a web form. However, one of the fields I can get is a foreign key to a resource, and I need to valide it then coerce it into a complete JSON object (the entry in a database related to said foreign key).

Is there a way for me to include this check and coercion in jjv?

If jjv does not allow this, is it a planned feature? One way to do it would be to check and apply asynchronous logic if 1 < Function.length, both for validation and coercion.

As an example, my use case is this:
I have a user-provided JSON in this form:

{
  "idToForeign": 1234,
  "credentials": {
    "username": "robert",
    "password": "pwd"
  }
}

What I need to validate is that idToForeign is an integer, has a related entry in the database that I will fetch a second later and has permission to reference it. Permission may not be validable with jjv, as jjv does not (and, in my understanding, does not mean to) allow validation of fields in relation with each other, but I still would like to check and fetch said entry during the jjv validation / coercion, before processing this input.


Thanks a bunch in advance!

Regards,

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

1 participant