Add function for validating ZIP codes (somewhat)

This commit is contained in:
2023-11-08 02:18:34 +01:00
parent d83ed2d0eb
commit a03f072a69
4 changed files with 56 additions and 28 deletions

View File

@ -392,6 +392,27 @@ final class MD_STD_IN {
}
/**
* Validates a ZIP code.
*
* @param string $input Input string.
*
* @return string
*/
public static function validate_zip_code(string $input):string {
if (($input = trim($input)) === "") {
return "";
}
if (\mb_strlen($input) > 7) {
throw new MDgenericInvalidInputsException("ZIP code is too long");
}
return $input;
}
/**
* Returns an UTF8 version of a string.
*