def __call__(self, v): if v: if v.startswith('www.'): v = 'http://%s' % v try: validate.is_url(v, with_scheme=True) except Invalid: msg = u"Must start with 'http://', 'https://', or 'www.'" raise Invalid(msg, validator=self)
def __call__(self, v): if v: if v.startswith("www."): v = "http://%s" % v try: validate.is_url(v, with_scheme=True) except Invalid, e: msg = u"Must start with 'http://', 'https://', or 'www.'" raise Invalid(msg, validator=self)
def __call__(self, v): try: validate.is_url(v, full=self.full, absolute=self.absolute, relative=self.relative, messages=self.messages) except Invalid, e: raise Invalid(e.message, validator=self)
def test_validate_withoutscheme(self): fn = lambda v: validate.is_url(v, with_scheme=True) self.section = 'fail' values = [ 'foo.com', ] check_fail('function', self, fn, values)
def test_validate_pass_relative(self): fn = lambda v: validate.is_url(v, full=False, relative=True, absolute=False) self.section='pass' values = [ 'foo', ] check_pass('function', self, fn, values)
def test_validate_pass_withoutscheme(self): fn = lambda v: validate.is_url(v, with_scheme=True) self.section = 'pass' values = [ 'http://foo.com', ] check_pass('function', self, fn, values)
def test_validate_full(self): fn = lambda v: validate.is_url(v, full=True, absolute=False, relative=False) self.section='fail' values = [ 'foo.com', ] check_fail('function', self, fn, values)
def test_validate_withoutscheme(self): fn = lambda v: validate.is_url(v, with_scheme=True) self.section='fail' values = [ 'foo.com', ] check_fail('function', self, fn, values)
def test_validate_pass_withoutscheme(self): fn = lambda v: validate.is_url(v, with_scheme=True) self.section='pass' values = [ 'http://foo.com', ] check_pass('function', self, fn, values)
def test_validate_pass_relative(self): fn = lambda v: validate.is_url( v, full=False, relative=True, absolute=False) self.section = 'pass' values = [ 'foo', ] check_pass('function', self, fn, values)
def test_validate_full(self): fn = lambda v: validate.is_url( v, full=True, absolute=False, relative=False) self.section = 'fail' values = [ 'foo.com', ] check_fail('function', self, fn, values)
def __call__(self, v): try: validate.is_url(v, with_scheme=self.with_scheme, messages=self.messages) except Invalid, e: raise Invalid(e.message, validator=self)