Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 594FB7503 for ; Tue, 4 Oct 2011 12:41:51 +0000 (UTC) Received: (qmail 5752 invoked by uid 500); 4 Oct 2011 12:41:49 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 5711 invoked by uid 500); 4 Oct 2011 12:41:49 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 5703 invoked by uid 99); 4 Oct 2011 12:41:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 12:41:49 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of marcello.nuccio@gmail.com designates 209.85.210.46 as permitted sender) Received: from [209.85.210.46] (HELO mail-pz0-f46.google.com) (209.85.210.46) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 12:41:44 +0000 Received: by pzk33 with SMTP id 33so1377403pzk.5 for ; Tue, 04 Oct 2011 05:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=TUY7L+YEInMECs3ab56kTlLbYORv3bFzK4kZeJc3B3o=; b=Ss+6pkdfhmODo2Sw9rX120hOxtZberhabzbWSUUuB34Hd48DU7FIhfxQHmpNzNbn4Y 2X26eutJ5P3KidAhVpHgFcnbnlM1+6EN5dks3xPyv4zZ9QWi6gNsGhTMQgCVFmjHg4G1 TKrUVgMCWZ4b81jyGsekUQgVLbtCxjVTalkqw= MIME-Version: 1.0 Received: by 10.68.9.2 with SMTP id v2mr9215818pba.101.1317732084707; Tue, 04 Oct 2011 05:41:24 -0700 (PDT) Received: by 10.143.90.15 with HTTP; Tue, 4 Oct 2011 05:41:24 -0700 (PDT) In-Reply-To: References: Date: Tue, 4 Oct 2011 14:41:24 +0200 Message-ID: Subject: Re: Allowed contents of validate_doc_update field. From: Marcello Nuccio To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yes, it works. But I want to use the modules on the browser and I've managed to get it working using RequireJS. Unfortunately I have problems with js-test-driver, so right now I'm doing file concatenation to get the job done. Marcello 2011/10/4 Sean Copenhaver : > Do CommonJS modules work in validate_doc_update? > > On Tue, Oct 4, 2011 at 8:04 AM, Jason Smith wrote: > >> I would stick to a pure-function. What if you set `a =3D /not_bla/` in >> the function? But CouchDB might start many simultaneous Javascript >> processes, so you will not know the value of `a` later. >> >> I admit that sometimes I wish I could put constants and other things >> outside the function, for readability. >> >> P.S. /regex/.test(str) does not work on some builds of CouchDB (or >> rather, some builds of Spidermonkey) which are still in use. It is >> safer to use str.match(/regex) which I also find less readable :) >> >> On Tue, Oct 4, 2011 at 3:35 PM, Marcello Nuccio >> wrote: >> > Is it supported to put anything other than an anonymous function in >> > the validate_doc_update field of a design document? >> > >> > For example: >> > >> > =C2=A0 =C2=A0var a =3D /bla/; >> > =C2=A0 =C2=A0function (doc, oldDoc, userCtx, secObj) { >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!a.test(doc._id)) ... >> > =C2=A0 =C2=A0} >> > >> > is it supported or it can work only by coincidence. >> > >> > Thanks, >> > =C2=A0Marcello >> > >> >> >> >> -- >> Iris Couch >> > > > > -- > =E2=80=9CThe limits of language are the limits of one's world. =E2=80=9C = - Ludwig von > Wittgenstein > > "Water is fluid, soft and yielding. But water will wear away rock, which = is > rigid and cannot yield. As a rule, whatever is fluid, soft and yielding w= ill > overcome whatever is rigid and hard. This is another paradox: what is sof= t > is strong." - Lao-Tzu >