jump to navigation

IP Mask validator February 12, 2006

Posted by rossoft in CakePHP.

Added to my validator vendor package more validators (IpValidator and NetmaskValidator)

Example of usage (read the phpdoc info on the source files for full doc):

       array(VALID_NOT_EMPTY,'Not blank'),
       array(VALID_IP,'Not valid ip',array(true,'network','mask'))),
       array(VALID_NOT_EMPTY,'Not blank'),
       array(VALID_IP,'Not valid ip network')),
       array(VALID_NOT_EMPTY,'Not blank'),
       array(VALID_NETMASK,'Not valid network mask',array(false))));

This will validate:

  • The network_mask field is a valid mask. It can’t be in the short format because the param is false. If the param is true, then the mask could be in the short format.
  • The network field is a valid ip (it’s in the form xxx.xxx.xxx.xxx)
  • The ip field is a valid ip AND is a ip within the range of the network indicated in the field ‘network’ with the mask indicated in the field ‘mask’. If the first param is false, then the 2nd and 3rd parameter are the values directly, nor fields that holds these values.


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: