The validators that need no model
Lesson 4 read the record one validator left behind. That validator, ValidLength, arrived from PyPI, and nine more like it are one pip install away. This lesson is where they come from and which of them cost nothing to run.
What the hub is now
Guardrails Hub is the catalogue of pre-built checks. For most of the library's life it was a private registry: you ran guardrails configure, pasted a token, and installed a validator with guardrails hub install hub://guardrails/detect_pii. Almost every tutorial online still shows that.
Version 0.11.0 retired it. The Migrating to 0.11.0 page states that the registry and the hosted inference endpoints shut down on 6 August 2026, that validators are now public PyPI packages named guardrails-ai-<name>, and that no token is needed to install one. The registered name of each validator did not change, so only the import line moves.
# the old way, still shown nearly everywhere
guardrails hub install hub://guardrails/valid_length
# the way that works now
pip install guardrails-ai-valid-lengthThe old import path still works and tells you it is on its way out.
import warnings
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
from guardrails.hub import ValidLength
hub = next(w for w in caught if "guardrails.hub" in str(w.message))
print(hub.category.__name__)
print(str(hub.message)[:78])What you actually have installed
The CLI is no help here. guardrails hub list still exists, prints a deprecation notice, reads a registry file that pip never writes, and reports that nothing is installed even when ten validators are. Python's own package metadata is the honest answer.
from importlib.metadata import distributions
names = sorted(dist.metadata["Name"] for dist in distributions()
if (dist.metadata["Name"] or "").startswith("guardrails-ai-"))
for name in names:
print(name)Ten of those are validators. guardrails-ai-types is not a check at all; it is the shared package that holds FailResult and friends, and it arrives as a dependency of everything else.
The ten that need nothing
Most of the interesting entries in the hub carry a machine learning model: toxicity, PII detection, competitor checking, topic relevance. Those download hundreds of megabytes the first time you construct them. These ten do not. They are plain Python, and they are why this course runs offline.
| Import | Class | Checks that the value |
|---|---|---|
| guardrails_ai.valid_length | ValidLength | is between min and max characters |
| guardrails_ai.valid_range | ValidRange | is a number between min and max |
| guardrails_ai.valid_choices | ValidChoices | is one of a list you supply |
| guardrails_ai.regex_match | RegexMatch | matches a regular expression |
| guardrails_ai.ends_with | EndsWith | ends with a given string |
| guardrails_ai.two_words | TwoWords | is exactly two words |
| guardrails_ai.lowercase | LowerCase | is all lower case |
| guardrails_ai.valid_json | ValidJson | parses as JSON |
| guardrails_ai.valid_url | ValidURL | has a scheme and a host |
| guardrails_ai.web_sanitization | WebSanitization | contains no script or markup |
from guardrails import Guard
from guardrails_ai.valid_choices import ValidChoices
from guardrails_ai.valid_url import ValidURL
kind = Guard().use(ValidChoices(choices=["ship", "refund", "track"], on_fail="noop"))
print(kind.validate("refund").validation_passed)
print(kind.validate("cancel").validation_passed)
link = Guard().use(ValidURL(on_fail="noop"))
print(link.validate("https://shop.example/orders/8821").validation_passed)
print(link.validate("shop.example").validation_passed)ValidURL is worth opening, because its name suggests a network call. It is urllib.parse.urlparse and two if statements: a value passes when it has a scheme and a host. Nothing is fetched, which is one less thing that can make your test suite flaky.
- Install
guardrails-ai-two-wordsand check"support desk"and"the support desk". - Run
guardrails hub listin your terminal and compare it with the package list you printed above. - Look up one hub validator that does need a model, and read what it downloads before you install it.
Every expert started right here.