format method

ValidatorFn<XFile> format(
  1. Set<String> mimeType, [
  2. String? message
])

A file format validator.

Implementation

ValidatorFn<XFile> format(Set<String> mimeType, [String? message]) =>
    (XFile? value, BuildContext context) {
      final fileType = lookupMimeType(value?.path ?? '');

      if (value != null && !mimeType.contains(fileType)) {
        return message ??
            HookFormScope.of(context).invalidFileFormat(mimeType);
      }

      return this.call(value, context);
    };