Results for “Errors & validation”
Small, practical examples. Search by task or narrow things down below.
Distinguish end-of-input from other errors
Distinguish end-of-input from other errors using a complete Go program with explicit sample inputs.
Go✓ Tested
Parse an integer with validation
Validate range and trailing characters when parsing a C integer with strtol.
C✓ Tested
Show a field-specific validation message
Show a field-specific validation message with a small React component and explicit browser behavior.
React✓ Tested
Style a control that fails native validation
CSS: Invalid reflects the input’s current constraint-validation result.
CSS✓ Tested
Use native required-field validation
Use native required-field validation with a small React component and explicit browser behavior.
React✓ Tested
Accept one typed value at a time from a pipeline
PowerShell: An advanced function uses process to handle each pipeline item.
PowerShell✓ Tested
Accumulate pipeline input across begin process and end
PowerShell: Keep initialization and final output separate from per-item work.
PowerShell✓ Tested
Add context to a parsing failure
Add context to a parsing failure in a complete Rust program using the standard library.
Rust✓ Tested
Build a URL query string
Python: Use urlencode to percent-encode query parameter values correctly.
Python✓ Tested
Build text efficiently in a loop
Java: Append to StringBuilder when constructing a string incrementally.
Java✓ Tested
Build text incrementally with StringBuilder
C#: Append fragments instead of repeatedly concatenating intermediate strings in a loop.
C#✓ Tested
Calculate a page count with ceiling division
JavaScript: Use Math.ceil for a nonnegative item count and a positive page size.
JavaScript✓ Tested