yarn add detect-string-format
import returnFormatDetector from "detect-string-format";
usage
// quick start with default formats:const fastDetect =returnFormatDetector(); // returns a functionconst results =fastDetect(["0.0.0.0", "127.0.0.53", "127.0.0.1"]);
defaults:
const defaultFormats:JSONSchema7= ["date", "time", "date-time", "uri", "url", "email", "ipv4", "ipv6", "uuid"].map(format=> ({ format }));
// you may want to add any of these: // ["hostname", "json-pointer", "json-pointer-uri-fragment", "relative-json-pointer", "uri-reference", "regex"];
add custom formats/schemas
The following example matches a simple North American telephone number with an optional area code: