mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-11-29 11:42:35 +01:00
Check if the path is valid when using WithPath(...) (#1377)
This commit is contained in:
1 parent
dfeabf228e
commit
21601889e0
12 files changed
+82
-10
No files matched your search
@@ -0,0 +1,19 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
|
||||
namespace WireMock.Validators;
|
||||
|
||||
public static class PathValidator
|
||||
{
|
||||
/// <summary>
|
||||
/// A valid path must start with a '/' and cannot be null, empty or whitespace.
|
||||
/// </summary>
|
||||
public static void ValidateAndThrow(string? path, string? paramName = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path) || path?.StartsWith("/") == false)
|
||||
{
|
||||
throw new ArgumentException("Path must start with a '/' and cannot be null, empty or whitespace.", paramName ?? nameof(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user