Add function for validating ZIP codes (somewhat)

This commit is contained in:
jrenslin committed 2023-11-08 02:18:34 +01:00
1 parent d83ed2d0eb
commit a03f072a69
4 files changed
+56 -28

No files matched your search

+21
View File
@@ -392,6 +392,27 @@ public static function validate_isbn(string $input):string {
}
/**
* 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.
*