cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc-Aurèle Brothier <ma...@exoscale.ch>
Subject Re: Question about JavaScript validators in UI
Date Thu, 27 Oct 2016 05:52:53 GMT
>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 <wido@widodh.nl> 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 <wido@widodh.nl>
> > 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
> >
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message