Pimp Your Parameters: The Magic of Validation Classes
summary
Creates reusable classes that derive from ValidateArgumentsAttribute and implement a Validate(object arguments, EngineIntrinsics) method that throws on invalid and returns void, so bad input is rejected before function body runs. Demos include a ValidateIsNotFriday rule, a Jira ticket regex, a semver checker that strips leading v, enforces three parts, disallows components >999, a path validator that blocks UNC and “..” traversal and can restrict to a root, and a port validator that blocks well‑known ports by default. Note order matters — only first failure is reported and these work in PowerShell 5 where semver types are absent.
AI-written summary · about
chapters (10)
- 0:00Validation classes intro
- 1:15Built-in validation recap
- 2:18Why custom validation matters
- 4:47Custom validation class
- 7:13Custom validation examples
- 10:46Constructors for validation
- 14:55Advanced validation scenarios
- 18:29Port and path validation
- 20:15Key takeaways
- 24:53Q&A
related talks
24mPimp Your Parameters: The Magic of Transformation...
43mInput Validation in PureScript: Simpler, Safer, and Stronger (Part 1)
37mInput Validation in PureScript: Simpler, Safer, and Stronger (Part 2)
25mMaking Impossible States Impossible
21mBeyond Type Checking Building Bulletproof TypseScript Applications
17mRespect The Process
38mSafer TypeScript
34mType Your Business
