Skip to content

Commit ceaf2ba

Browse files
committed
Add mime
1 parent 5345227 commit ceaf2ba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/src/form_builder_validators.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,24 @@ class FormBuilderValidators {
794794
checkNullOrEmpty: checkNullOrEmpty,
795795
).validate;
796796

797+
/// [FormFieldValidator] that requires the field's value to be a valid MIME type.
798+
/// The MIME type should be in the format `type/subtype`.
799+
///
800+
/// ## Parameters:
801+
/// - [regex] The regex pattern to match.
802+
/// - [errorText] The error message when the file name is invalid.
803+
/// - [checkNullOrEmpty] Whether to check for null or empty values.
804+
static FormFieldValidator<String> mimeType({
805+
RegExp? regex,
806+
String? errorText,
807+
bool checkNullOrEmpty = true,
808+
}) =>
809+
MimeTypeValidator(
810+
regex: regex,
811+
errorText: errorText,
812+
checkNullOrEmpty: checkNullOrEmpty,
813+
).validate;
814+
797815
/// [FormFieldValidator] that applies another validator conditionally.
798816
///
799817
/// ## Parameters:

0 commit comments

Comments
 (0)