{"id":28085,"library":"pydantic-string-url","title":"Pydantic URL String Types","description":"Pydantic URL types based on str class for fast and simple URL validation. Current version 1.0.2, release cadence is low (semi-active maintenance). Provides Pydantic field types like HttpUrl, FtpUrl, etc., but unlike pydantic's own UrlStr, these are simple str subclasses that do not parse URL components.","status":"active","version":"1.0.2","language":"python","source_language":"en","source_url":"https://github.com/patrsc/pydantic-string-url","tags":["pydantic","url","validation","str-subclass"],"install":[{"cmd":"pip install pydantic-string-url","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency; provides BaseModel and field validation","package":"pydantic","optional":false}],"imports":[{"note":"pydantic's HttpUrl is different (UrlStr class). This library's HttpUrl is a str subclass with URL validation.","wrong":"from pydantic import HttpUrl","symbol":"HttpUrl","correct":"from pydantic_string_url import HttpUrl"},{"note":"No common wrong import; just ensure correct module name.","wrong":"","symbol":"FtpUrl","correct":"from pydantic_string_url import FtpUrl"}],"quickstart":{"code":"from pydantic import BaseModel\nfrom pydantic_string_url import HttpUrl, FtpUrl\n\nclass MyModel(BaseModel):\n    website: HttpUrl\n    ftp: FtpUrl\n\n# Valid\nm = MyModel(website='https://example.com', ftp='ftp://files.example.com')\nprint(m.website)  # 'https://example.com'\n\n# Invalid - raises ValidationError\n# m = MyModel(website='not-a-url', ftp='ftp://example.com')","lang":"python","description":"Define a Pydantic model with URL fields. The URL types validate the string is a proper URL, but keep it as a plain string (not parsed into components)."},"warnings":[{"fix":"Use str(your_url_field) to get a plain string, or use .__str__() if needed for serialization.","message":"Types in this library are str subclasses, not UrlStr; use str() to get plain string if you need to disable subclass behavior.","severity":"breaking","affected_versions":"all"},{"fix":"If you need URL parsing (e.g., url.host), use from pydantic import HttpUrl instead of pydantic_string_url.","message":"This library's HttpUrl does NOT parse the URL into components like scheme, host, port. It only validates format. Use pydantic's HttpUrl if you need parsed access.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use 'from pydantic_string_url import HttpUrl' for this library's version. Or use 'from pydantic import HttpUrl' for pydantic's parsed URL type.","cause":"User imported HttpUrl from pydantic instead of pydantic_string_url. pydantic's HttpUrl exists but is different.","error":"ImportError: cannot import name 'HttpUrl' from 'pydantic'"},{"fix":"Ensure URL starts with http://, https://, ftp://, etc. and conforms to standard URL format.","cause":"The URL string does not match the expected pattern (e.g., missing scheme or invalid format).","error":"pydantic.error_wrappers.ValidationError: 1 validation error for MyModel\nwebsite\n  invalid or missing URL (type=value_error.url)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}