Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D0DC9200BBB for ; Thu, 27 Oct 2016 07:53:02 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CF822160AFD; Thu, 27 Oct 2016 05:53:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 23916160AEE for ; Thu, 27 Oct 2016 07:53:01 +0200 (CEST) Received: (qmail 23086 invoked by uid 500); 27 Oct 2016 05:53:01 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 23070 invoked by uid 99); 27 Oct 2016 05:53:00 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2016 05:53:00 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id C89791A05CC for ; Thu, 27 Oct 2016 05:52:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.998 X-Spam-Level: * X-Spam-Status: No, score=1.998 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=exoscale-ch.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id fkUARfjxXB4m for ; Thu, 27 Oct 2016 05:52:57 +0000 (UTC) Received: from mail-oi0-f47.google.com (mail-oi0-f47.google.com [209.85.218.47]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id DA37A5FC0D for ; Thu, 27 Oct 2016 05:52:56 +0000 (UTC) Received: by mail-oi0-f47.google.com with SMTP id y2so36787014oie.0 for ; Wed, 26 Oct 2016 22:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=exoscale-ch.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=e27jxwrpAInwBnpma2zVPMNcemYDb9gAra4HcwEtjoQ=; b=VYjaw2cDyvhSkqm52wfhHVNFk+eEcenc39wWOx8Sq39t/+cidyLlEnWjKL1L3TPJPK e+TOJVanvMkHp/5H8VYniEiJApYrMVZpw5o19Oi7s5YQvnk4UOIcUNnNd04P+IMwkuEK 1ABntm4MePZRKVF0LqlhPPsTx8ionYMIHQKxCUYUBW7ZTApaYzWOoYGAmydZ2eNFlYxA g70h5DislqPVLeTpDOftVpsIY+/aIYP1e0LvoepK0s7an2LcGpu0cIbSN/lTrZsjpEoh d5SbHQ86S4kEn/SDvKRAimS0L4V7hXkZlIDBJFCIB5B8qE0eibw1wyxWipjGf5O89fRZ BSFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=e27jxwrpAInwBnpma2zVPMNcemYDb9gAra4HcwEtjoQ=; b=SKYjabCdoipjK+FKJ0H0LZP14oZrn/FNiyHvsi6qyl2VDMBKkbfukGMrHua7yhUmRm q/C23nGzQ99mSfmf8FDny1e19B0WNwmkIJSgpwJWX8kSFkesjq6kLA8YNCrN5J5aEf3t 7boH6X7are24GNuRWJJ8XzZolvYtBndZ7fa1PqnvKTRX4vqa/HPemFrr+5xhLUEl5gY/ nmXDVYYbupzHOG5k3i0Q3vQog6fUhQD2Ycn/B0sirQRc5SAD1k2gG1QMb5DoBFz/bFTO c+s1+qQEBSWJXWZDH/w42y3GslBT6M3ydrF29Rljxn1BXDWEUNRM9Akg+EDqrNMXNAvX IXtQ== X-Gm-Message-State: ABUngvf57rEsBPUUny1TnXXCE4ylGGrnB2me3ftjES/JwKlzOjm8rfBupS47CHZM+/YdPjhd0cuKVqcDs1+fbw== X-Received: by 10.107.164.209 with SMTP id d78mr5410039ioj.182.1477547573759; Wed, 26 Oct 2016 22:52:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.169.140 with HTTP; Wed, 26 Oct 2016 22:52:53 -0700 (PDT) In-Reply-To: <223909240.352.1477492664830@ox.pcextreme.nl> References: <1526673638.6445.1477051410077@ox.pcextreme.nl> <223909240.352.1477492664830@ox.pcextreme.nl> From: =?UTF-8?Q?Marc=2DAur=C3=A8le_Brothier?= Date: Thu, 27 Oct 2016 07:52:53 +0200 Message-ID: Subject: Re: Question about JavaScript validators in UI To: dev@cloudstack.apache.org Content-Type: multipart/alternative; boundary=001a11458f8445e626053fd25a34 archived-at: Thu, 27 Oct 2016 05:53:03 -0000 --001a11458f8445e626053fd25a34 Content-Type: text/plain; charset=UTF-8 From a quick look at the code you've forgotten one "|" for the or condition: $.validator.addMethod("ipv46cidr", function(value, element) { if (!$.validator.methods.ipv4cidr.call(this, value, element) || !$.validator.methods.ipv6cidr.call(this, value, element)) return false; return true; }, "The specified IPv4/IPv6 CIDR is invalid."); On Wed, Oct 26, 2016 at 4:37 PM, Wido den Hollander wrote: > So my JS skills are way to low, but I tried this, but it doesn't seem to > work: > > $.validator.addMethod("ipv46cidr", function(value, element) { > if (!$.validator.methods.ipv4cidr.call(this, value, element) | > !$.validator.methods.ipv6cidr.call(this, value, element)) > return false; > > return true; > }, "The specified IPv4/IPv6 CIDR is invalid."); > > What am I missing here? > > Wido > > > Op 23 oktober 2016 om 9:37 schreef Rohit Yadav < > rohit.yadav@shapeblue.com>: > > > > > > Hi Wido, > > > > > > Yes, you can add a new validator that can validator that the provided > address is either ipv4 or ipv6, here: > > > > https://github.com/apache/cloudstack/blob/master/ui/ > scripts/sharedFunctions.js#L2327 > > > > > > Give the validator any appropriate name, and use it in the network.js > code replacing the currently defined validator with yours. > > > > > > Regards. > > > > ________________________________ > > From: Wido den Hollander > > Sent: 21 October 2016 17:33:29 > > To: dev@cloudstack.apache.org > > Subject: Question about JavaScript validators in UI > > > > Hi, > > > > While working on the IPv6 for Basic Networking I'm at the stage of the > Security Groups. > > > > When entering a CIDR in the UI which is not IPv4 (eg ::/0) it will show: > 'The specified IPv4 CIDR is invalid.' > > > > That's true, so looking in network.js I see this piece of code: > > > > 'cidr': { > > edit: true, > > label: 'label.cidr', > > isHidden: true, > > validation: { > > ipv4cidr: true > > } > > }, > > > > There is a ipv6cidr validation method as well. How can I modify the > JavaScript in such a way that either a valid IPv4 OR IPv6 CIDR has to be > entered? > > > > My JavaScript skills are rather low. > > > > Thanks! > > > > Wido > > > > rohit.yadav@shapeblue.com > > www.shapeblue.com > > 53 Chandos Place, Covent Garden, London WC2N 4HSUK > > @shapeblue > > > > > > > --001a11458f8445e626053fd25a34--