-
Notifications
You must be signed in to change notification settings - Fork 14
CouchDB Validation Functions in Scala
debasishg edited this page Sep 13, 2010
·
1 revision
// Create a document with pass thru validation function in design document // create a design document with a validation function in Scala that passes thru everything val vfn = """(ndoc: dispatch.json.JsValue, odoc: dispatch.json.JsValue, req: Any) => {}""" val d = DesignDocument("foo_1", null, Map[String, View](), vfn) d.language = "scala" val de = Doc(test, d._id) d._id should equal("_design/foo_1") http(de add d) // creation of a document should be successful http(test doc Js("""{"item":"oranges","prices":{"Fresh Mart":1.99,"Price Max":3.19,"Citrus Circus":1.09}}"""))
Validation functions can be more complicated and all features of Scala can be used to do meaningful validation for documents. Have a look at ScalaValidationSpec test suite for details.