(cls, obj, raiseException=False, complainUnrecognized=False)
Check if the object satisfies this behavior's requirements.

        @param obj:
            The L{ContentLine<base.ContentLine>} or
            L{Component<base.Component>} to be validated.
        @param raiseException:
            If True, raise a L{base.ValidateError} on validation failure.
            Otherwise return a boolean.
        @param complainUnrecognized:
            If True, fail to validate if an uncrecognized parameter or child is
            found.  Otherwise log the lack of recognition.
Check if the object satisfies this behavior's requirements.
Check if the object satisfies this behavior s requirements .
def validate(cls, obj, raiseException=False, complainUnrecognized=False):
        """Check if the object satisfies this behavior's requirements.

        @param obj:
            The L{ContentLine<base.ContentLine>} or
            L{Component<base.Component>} to be validated.
        @param raiseException:
            If True, raise a L{base.ValidateError} on validation failure.
            Otherwise return a boolean.
        @param complainUnrecognized:
            If True, fail to validate if an uncrecognized parameter or child is
            found.  Otherwise log the lack of recognition.

        """
        if not cls.allowGroup and obj.group is not None:
            err = "{0} has a group, but this object doesn't support groups".format(obj)
            raise base.VObjectError(err)
        if isinstance(obj, base.ContentLine):
            return cls.lineValidate(obj, raiseException, complainUnrecognized)
        elif isinstance(obj, base.Component):
            count = {}
            for child in obj.getChildren():
                if not child.validate(raiseException, complainUnrecognized):
                    return False
                name = child.name.upper()
                count[name] = count.get(name, 0) + 1
            for key, val in cls.knownChildren.items():
                if count.get(key, 0) < val[0]:
                    if raiseException:
                        m = "{0} components must contain at least {1} {2}"
                        raise base.ValidateError(m .format(cls.name, val[0], key))
                    return False
                if val[1] and count.get(key, 0) > val[1]:
                    if raiseException:
                        m = "{0} components cannot contain more than {1} {2}"
                        raise base.ValidateError(m.format(cls.name, val[1], key))
                    return False
            return True
        else:
            err = "{0} is not a Component or Contentline".format(obj)
            raise base.VObjectError(err)
def validate ( cls , obj , raiseException = False , complainUnrecognized = False ) : if not cls . allowGroup and obj . group is not None : err = "{0} has a group, but this object doesn't support groups" . format ( obj ) raise base . VObjectError ( err ) if isinstance ( obj , base . ContentLine ) : return cls . lineValidate ( obj , raiseException , complainUnrecognized ) elif isinstance ( obj , base . Component ) : count = { } for child in obj . getChildren ( ) : if not child . validate ( raiseException , complainUnrecognized ) : return False name = child . name . upper ( ) count [ name ] = count . get ( name , 0 ) + 1 for key , val in cls . knownChildren . items ( ) : if count . get ( key , 0 ) < val [ 0 ] : if raiseException : m = "{0} components must contain at least {1} {2}" raise base . ValidateError ( m . format ( cls . name , val [ 0 ] , key ) ) return False if val [ 1 ] and count . get ( key , 0 ) > val [ 1 ] : if raiseException : m = "{0} components cannot contain more than {1} {2}" raise base . ValidateError ( m . format ( cls . name , val [ 1 ] , key ) ) return False return True else : err = "{0} is not a Component or Contentline" . format ( obj ) raise base . VObjectError ( err )