rethinkdb / horizon

Horizon is a realtime, open-source backend for JavaScript apps.
MIT License
6.78k stars 350 forks source link

Add server validation of documents #138

Open deontologician opened 8 years ago

deontologician commented 8 years ago

This is to enable a write to go through by validating that the resulting document is valid, but is separate from security rules

dalanmiller commented 8 years ago

Where would one specify the required schema? Via a config file?

deontologician commented 8 years ago

Yeah, it'll have to be.

deontologician commented 8 years ago

Things that were discussed:

danielmewes commented 8 years ago

Not settled whether to fail if any write doesn't validate, or just to keep going and report failures

I think validation only makes sense if we fail. The case where we weren't sure was for reads (whether to filter out documents that the user doesn't have permissions on, or fail).

Another thing that we discussed: In addition to json-schema validation, advanced users could also install their own atomic ReQL validation functions (but not arbitrary JS).

josephg commented 8 years ago

Yeah this would be great. Its irresponsible to allow clients to store arbitrary documents - you really want some (simple) schema validation for almost anything you store.

Calling schema validation code from inlined javascript strings in config.toml is super awkward.

sachinbhutani commented 8 years ago

It would be great, if it could be a generic hook, which may be used for validation change update or something else. Also, could it be isomorphic ?

kiejo commented 8 years ago

Making it isomorphic would be great as this should make it easier to implement offline support with optimistic updates.

What might also be interesting would be to include transformation capabilites which would allow using functions like trim or toLowerCase on fields.