@@ -74,6 +74,11 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
7474 date, date-time, email, ipv4, ipv6, regex, uuid
7575
7676\b
77+ For the "email" and "idn-email" formats, there are multiple modes which can be specified with
78+ '--format-email':
79+ default | only check that the string contains "@"
80+ full | check the string against RFC 5321 (email) or RFC 6531 (idn-email)
81+
7782For the "regex" format, there are multiple modes which can be specified with
7883'--format-regex':
7984 default | check that the string is a valid ECMAScript regex
@@ -155,6 +160,16 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
155160 default = RegexVariantName .default .value ,
156161 type = click .Choice ([x .value for x in RegexVariantName ], case_sensitive = False ),
157162)
163+ @click .option (
164+ "--format-email" ,
165+ help = (
166+ "Set the mode of format validation for email addresses. "
167+ "If `--disable-formats email` or `--disable-formats idn-email` is "
168+ "used, this option has no effect on the disabled format."
169+ ),
170+ default = EmailVariantName .default .value ,
171+ type = click .Choice ([x .value for x in EmailVariantName ], case_sensitive = False ),
172+ )
158173@click .option (
159174 "--default-filetype" ,
160175 help = "A default filetype to assume when a file's type is not detected" ,
@@ -240,6 +255,7 @@ def main(
240255 no_cache : bool ,
241256 cache_filename : str | None ,
242257 disable_formats : tuple [list [str ], ...],
258+ format_email : Literal ["full" , "default" ],
243259 format_regex : Literal ["python" , "default" ],
244260 default_filetype : Literal ["json" , "yaml" , "toml" , "json5" ],
245261 traceback_mode : Literal ["full" , "short" ],
@@ -267,6 +283,7 @@ def main(
267283 else :
268284 args .disable_formats = normalized_disable_formats
269285
286+ args .format_email = RegexVariantName (format_email )
270287 args .format_regex = RegexVariantName (format_regex )
271288 args .disable_cache = no_cache
272289 args .default_filetype = default_filetype
0 commit comments