Validation
The process of verifying that input data conforms to specified formats, ranges, and constraints. Includes character count limits, character type checks, and format verification.
Validation is the process of confirming that data entered by users or exchanged between systems meets expected conditions. Is the email address in the form properly formatted? Does the password meet the minimum length requirement? Is the phone number composed entirely of digits? These are all concrete examples of validation in action.
Validation falls into two categories based on where it runs. Client-side validation executes in the browser and provides immediate feedback, improving the user experience. HTML5 attributes like required, maxlength, and pattern, along with dynamic JavaScript checks, fall into this category. Server-side validation performs the final verification on the server and is the security backstop. Because client-side checks can be trivially bypassed using browser developer tools, server-side validation is never optional.
Character count validation is one of the most fundamental and frequently encountered patterns. X (formerly Twitter) enforces a 280-character limit, SMS messages are capped at 160 characters in GSM-7 encoding (70 characters for Unicode messages), and database VARCHAR columns have fixed upper bounds. The tricky part is defining what counts as "one character." The family emoji 👨👩👧👦 looks like a single character, but in Unicode it consists of seven code points (four person emoji joined by three ZWJ characters). Whether a platform counts this as 1 character or 7 varies, so validation implementations must clearly define their counting method.
Character type validation is equally important. Web forms often enforce constraints like "letters and digits only" or "no special characters." Regular expressions such as /^[a-zA-Z0-9]+$/ handle these checks, but edge cases abound: accented characters (é, ñ), ligatures, and characters from non-Latin scripts all require careful consideration. A "letters only" rule that rejects valid names like "O'Brien" or "García" creates a poor user experience. Web form design books on Amazon cover these patterns in detail.
Format validation checks whether data matches expected patterns for email addresses, URLs, dates, postal codes, and similar structured inputs. A fully RFC 5321-compliant email regex is extraordinarily complex, so in practice most systems use a simplified pattern and ultimately verify deliverability by sending a confirmation email.
The design of validation error messages directly affects quality. "Input error" tells the user nothing useful. "Password must be at least 8 characters and include both letters and numbers" clearly states what is wrong and how to fix it. Error messages themselves are subject to length constraints (mobile screen widths, tooltip maximum lengths), demanding concise yet clear wording.