In computer programming, a magic string is an input that a programmer believes will never come externally and which activates otherwise hidden functionality.
Common issues that might lead to this anti-pattern as a result: Restricting the format of the input is a possible maintenance (bug fixing) solution — essentially this means validating input information to check that it is in the correct format, in order to reduce the possibility of the magic string being discovered by the user.
Examples include validating a telephone number to ensure that it contains only digits (and possibly spaces and punctuation to a limited extent) or checking that a person's name has a forename and a surname (and is appropriately capitalised).
As is often the case with anti-patterns, there exist specific scenarios where magic strings are a correct solution for an implementation.
Furthermore, there are cases when users invent magic strings, and systems that have not coded to accept them can produce unexpected results such as missing license plates.