nowfound

Dev tools · November 9, 2025

VF

Valid8r, Functional validation for Python CLIs using Maybe monads

I built Valid8r because I got tired of writing the same input validation code for every CLI tool. You know the pattern: parse a string, check if it's valid, print an error if not, ask again. Repeat for every argument. The library uses Maybe monads (Success/Failure instead of exceptions) so you can chain parsers and validators: # Try it: pip install valid8r from valid8r.core import parsers, validators # Parse and validate in one pipeline result = ( parsers.parse_int(user_input) .bind(validators.minimum(1)) .bind(validators.maximum(65535)) ) match result: case Success(port): print(f"Using…

What it does

In the maker’s words, at launch

I built Valid8r because I got tired of writing the same input validation code for every CLI tool. You know the pattern: parse a string, check if it's valid, print an error if not, ask again. Repeat for every argument. The library uses Maybe monads (Success/Failure instead of exceptions) so you can chain parsers and validators: # Try it: pip install valid8r from valid8r.core import parsers, validators # Parse and validate in one pipeline result = ( parsers.parse_int(user_input) .bind(validators.minimum(1)) .bind(validators.maximum(65535)) ) match result: case Success(port): print(f"Using port {port}") case Failure(error): print(f"Invalid: {error}") I built integrations for argparse, Click, and Typer so you can drop valid8r parsers directly into your existing CLIs without refactoring everything. The interesting technical bit: it's 4-300x faster than Pydantic for simple parsing (ints, emails, UUIDs) because it doesn't build schemas or do runtime type checking. It just parses strings and returns Maybe[T]. For complex nested validation, Pydantic is still better. I benchmarked both and documented where each one wins. I'm not trying to replace Pydantic. If you're building a FastAPI service, use Pydantic. But if you're building CLI tools or parsing network configs, Maybe monads compose really nicely and keep your code functional. The docs are at https://valid8r.readthedocs.io/ and the benchmarks are in the repo. It's MIT licensed. Would love feedback on the API design. Is the Maybe monad pattern too weird for Python, or does it make validation code cleaner? --- Here are a few more examples showing different syntax options for the same port validation: from valid8r.core import parsers, validators # Option 1: Combine validators with & operator validator = validators.minimum(1) & validators.maximum(65535) result = parsers.parse_int(user_input).bind(validator) # Option 2: Use parse_int_with_validation (built-in) result = parsers.parse_int_with_validation( user_input, validators.minimum(1) & validators.maximum(65535) ) # Option 3: Interactive prompting (keeps asking until valid) from valid8r.prompt import ask port = ask( "Enter port number (1-65535): ", parser=lambda s: parsers.parse_int(s).bind( validators.minimum(1) & validators.maximum(65535) ) ) # port is guaranteed valid here, no match needed # Option 4: Create a reusable parser function def parse_port(text): return parsers.parse_int(text).bind( validators.minimum(1) & validators.maximum(65535) ) result = parse_port(user_input) The & operator is probably the cleanest for combining validators. And the interactive prompt is nice because you don't need to match Success/Failure, it just keeps looping until the user gives you valid input.

Does the same job

all alternatives →

More dev tools this month

the category →
  • Dograh592

    The open source VAPI alternative

    Dev tools · 25d ago · dograh.com

  • Meridian530

    Don't let your work go unnoticed. Get promoted!

    Dev tools · 20d ago · meridiona.com

  • x1516

    Lovable for iPhone apps go from idea to App Store

    Dev tools · 11d ago · x1.new

  • Open-source GTM skills for technical founders

    Dev tools · 29d ago · gtmcofounder.com

  • OpenTrailPaper is open-source bike computer firmware for the LilyGO T5S3 4.7" E-Paper PRO. It supports offline maps, GPX routes, FIT recording and Bluetooth sensors.

    Dev tools · 1d ago · opentrailpaper.com

  • Nuphos380

    The AI-Native DevOps Workspace.

    Dev tools · 24d ago · nuphos.ai

Launched alongside, November 2025

the whole month →
  • Guideflow1,341

    The AI demo automation platform for SaaS

    AI · Nov 2025 · guideflow.com

  • IB

    Life & fun · Nov 2025 · bitsnpieces.dev

  • Welltory1,030

    Stop energy drain

    Work · Nov 2025 · welltory.com

  • Gemini 31,007

    Bring any idea to life with multimodal capabilities

    AI · Nov 2025 · blog.google

  • TrustMRR836

    The database of verified startup revenues

    Growth · Nov 2025 · trustmrr.com

  • B
    Boing782

    Life & fun · Nov 2025 · boing.greg.technology