Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/MimeTypes/MimeTypeFunctions.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ namespace $rootnamespace$
.Select(keyPair => keyPair.Key);
}

/// <summary>
/// Attempts to validate MIME-type.
/// </summary>
/// <param name="mimeType">The name of the MIME-type</param>
/// <returns><c>true</c> if a MIME-type was found, <c>false</c> otherwise</returns>
public static bool IsValidMimeType(string mimeType)
{
if (mimeType is null)
{
throw new ArgumentNullException(nameof(mimeType));
}

return s_typeMap
.Any(keyPair => string.Equals(keyPair.Value, mimeType, StringComparison.OrdinalIgnoreCase));
}

/// <summary>
/// Tries to get the MIME-type for the given file name.
/// </summary>
Expand Down