Results for “Numbers & numeric validation”
Small, practical examples. Search by task or narrow things down below.
Give an LED pin a constant name
Arduino / C: Use const to name the built-in LED pin and reuse it in output instructions.
Arduino / C✓ Tested
Limit typed text to a maximum length
HTML: Maxlength limits ordinary user editing without replacing server-side validation.
HTML✓ Tested
Narrow a union using typeof
Handle text and numeric values with separate branches.
union✓ Tested
Number rows within each group
Assign ordered row numbers with a window function.
row_number✓ Tested
Pad a label with leading zeroes
PowerShell: Use a numeric format specifier to control the displayed width.
PowerShell✓ Tested
Parse an integer safely
Handle invalid Java integer input with NumberFormatException.
Java✓ Tested
Raise and catch a domain-specific exception
Python: Give a validation failure its own exception type so callers can handle it narrowly.
Python✓ Tested
Read an integer from serial input
Arduino / C: parseInt skips leading nonnumeric characters and reads the next integer.
Arduino / C✓ Tested
Read named regex capture groups
JavaScript: Named groups make a fixed input format easier to inspect than numeric group positions.
JavaScript✓ Tested
Read named regex capture groups
TypeScript: Named groups make a fixed input format easier to inspect than numeric group positions.
TypeScript✓ Tested
Require a nonempty text value
HTML: The required attribute makes an empty text control fail native constraint validation.
HTML✓ Tested
Require a value with NOT NULL
SQL: Declare required fields at the database boundary, not only in application validation.
SQL✓ Tested