thanks for the reply. I will find the validator which has to run both on client and server side.
On Fri, Mar 1, 2013 at 4:38 PM, Geerten van Meel <[email protected]> wrote: > Since you did not get any answers so far, let me drop a few thoughts: > > First off, while it is possible to re-use code between client and server, > it is not a design goal of node to make this especially easy or encourage > this in a special way. It is possible because it's both JavaScript, yes, > but not necessarily a good thing to do. > > To achieve what you are looking for, search for any json schema validator > that runs both on node and can be included on the client side. With a few > lines of code (thus checking for the existance of "module" and > "module.exports", google it) you can usually wrap any client side library > into a node module for use on the server and then use almost the exact same > api to fullfill your task. > > However, you would still have to somehow get the logic / schema into both > your clients form handling and your server logic. Given that this would > require extra http requests or file lookups on one end or the other, or > copy&pasting the schema, you should ask whether there is a real benefit of > doing that. In my personal opinion, the required extra "juice" to make that > work does not stand against the small benefit of being able to share the > same code base. > > So long story short, find a npm module that does schema validation both on > the server and has a script to include on the client. Or don't. (I don't > like schema validation.) > > > On Wednesday, February 27, 2013 12:59:13 PM UTC+1, Srividhya wrote: >> >> Hi All, >> How can i use the same validation code on both client and server side >> (for reusability of code). Am using the jsonschema.js validator file on >> client side. When i submiting the data to the server i want to revalidate >> the data by using the same schema. If anyone knows means let me know. >> >> >> Thanks, >> sri >> > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Thanks, N. Srividhya. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
