Ejemplo n.º 1
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     # from http://www.regular-expressions.info/email.html
     regStrg = r"^#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$"
     if not match(regStrg, value.lower()):
         raise ColorValidError(value, 1)
Ejemplo n.º 2
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     try:
         physical_quantity = physq(1.0, value)
     except magnitude.MagnitudeError:
         raise PhysicalUnitValidError(value, 1)
Ejemplo n.º 3
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     try:
         ## we only try to initialize an instance of IPy
         ip = IP(value)
     except:
         raise NetIpValidError(value, 1)
Ejemplo n.º 4
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     regStrg = r"([0-9A-F][0-9A-F]):([0-9A-F][0-9A-F]):" +\
             "([0-9A-F][0-9A-F]):([0-9A-F][0-9A-F]):" +\
             "([0-9A-F][0-9A-F]):([0-9A-F][0-9A-F])"
     if not match(regStrg, value.upper()):
         raise MacValidError(value, 1)
Ejemplo n.º 5
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     # from http://www.regular-expressions.info/email.html
     regStrg = r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+" +\
             "(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" +\
             "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+" +\
             "[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
     if not match(regStrg, value.lower()):
         raise EmailValidError(value, 1)
Ejemplo n.º 6
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     try:
         ## we only try to initialize an instance of IPy
         ip = IP(value)
     except:
         raise HostIpValidError(value, 1)
     if ip.strNetmask() != '255.255.255.255':
         raise HostNetmaskValidError(value, 1)
Ejemplo n.º 7
0
 def _validate(self, value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, value)
     valList = value.split(' ', 1)
     try:
         numerical_value = float(valList[0])
         if len(valList) > 1:
             physical_unit = physq(numerical_value, valList[1])
     except ValueError:
         raise PhysicalQuantityValidError(value, 1)
     except magnitude.MagnitudeError:
         raise PhysicalQuantityValidError(value, 1)
Ejemplo n.º 8
0
    def _validate(self, specurl):
        TextLine._validate(self, specurl)
        if (ISpecification.providedBy(self.context)
                and specurl == self.context.specurl):
            # The specurl wasn't changed
            return

        specification = getUtility(ISpecificationSet).getByURL(specurl)
        if specification is not None:
            specification_url = canonical_url(specification)
            raise LaunchpadValidationError(
                structured(self.errormessage, specurl, specification_url,
                           specification.title))
Ejemplo n.º 9
0
    def _validate(self, specurl):
        TextLine._validate(self, specurl)
        if (ISpecification.providedBy(self.context) and
            specurl == self.context.specurl):
            # The specurl wasn't changed
            return

        specification = getUtility(ISpecificationSet).getByURL(specurl)
        if specification is not None:
            specification_url = canonical_url(specification)
            raise LaunchpadValidationError(
                    structured(self.errormessage, specurl, specification_url,
                        specification.title))
Ejemplo n.º 10
0
 def _validate(self, arg_value):
     """ validation method for forms """
     ## call parent validations
     TextLine._validate(self, arg_value)
     try:
         value = str(arg_value)
         uid = value[:-1]
         crc = value[-1]
         icrc_cmp = 0
         int_list = [int(i,16) for i in uid]
         for i in int_list:
             icrc_cmp ^= i
         crc_cmp = u"%x" % icrc_cmp
         if crc != crc_cmp:
             raise ObjectIdValidError(value, 1)
     except:
         raise ObjectIdValidError(value, 1)