-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
solarthing/core/src/main/resources/me/retrodaredevil/couchdb/design/validation/readonly_auth.js
Lines 43 to 47 in ccf7500
| var currentMillis = +new Date(); | |
| var millisInPast = currentMillis - newDoc.dateMillis; | |
| if (millisInPast > 25 * 60 * 1000) { | |
| throw {forbidden: "dateMillis field is too far in the past!"} | |
| } |
This blocks replication as described here: https://guide.couchdb.org/draft/validation.html
https://docs.couchdb.org/en/stable/ddocs/ddocs.html#validate-document-update-functions
Document validation is optional, and each design document in the database may have at most one validation function. When a write request is received for a given database, the validation function in each design document in that database is called in an unspecified order. If any of the validation functions throw an error, the write will not succeed.
We should also consider not putting this validation logic in _design/packets because if we need to change it, then indices need to be recalculated or whatever.