Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/HotChocolate/Core/src/Types.Scalars/EmailAddressType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace HotChocolate.Types;
public partial class EmailAddressType : RegexType
{
private const string ValidationPattern =
"^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?"
+ "(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
@"^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?"
+ @"(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z";

[GeneratedRegex(ValidationPattern, RegexOptions.None, DefaultRegexTimeoutInMs)]
private static partial Regex CreateRegex();
Expand Down
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Types.Scalars/HexColorType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace HotChocolate.Types;
public partial class HexColorType : RegexType
{
private const string ValidationPattern =
"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$";
@"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})\z";

[GeneratedRegex(ValidationPattern, RegexOptions.None, DefaultRegexTimeoutInMs)]
private static partial Regex CreateRegex();
Expand Down
6 changes: 3 additions & 3 deletions src/HotChocolate/Core/src/Types.Scalars/IPv4Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace HotChocolate.Types;
public partial class IPv4Type : RegexType
{
private const string ValidationPattern =
"(^(?:(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}(?:0?0?"
+ "[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\\/(?:[0-9]|[1-2][0-9]|3[0"
+ "-2]))?)$)";
@"(^(?:(?:(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(?:0?0?"
+ @"[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\/(?:[0-9]|[1-2][0-9]|3[0"
+ @"-2]))?)\z)";

[GeneratedRegex(ValidationPattern, RegexOptions.None, DefaultRegexTimeoutInMs)]
private static partial Regex CreateRegex();
Expand Down
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Types.Scalars/IPv6Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class IPv6Type : RegexType
+ "1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}(?:0?0?[0-9]|0?[1-9][0-9]|1[0-9][0-9]|2["
+ "0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f"
+ "]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})?::)(?:\\/(?:0?0?[0-9]|0?["
+ "1-9][0-9]|1[01][0-9]|12[0-8]))?)$)";
+ "1-9][0-9]|1[01][0-9]|12[0-8]))?)\\z)";

[GeneratedRegex(ValidationPattern, RegexOptions.None, DefaultRegexTimeoutInMs)]
private static partial Regex CreateRegex();
Expand Down
12 changes: 6 additions & 6 deletions src/HotChocolate/Core/src/Types.Scalars/IsbnType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace HotChocolate.Types;
public partial class IsbnType : RegexType
{
private const string ValidationPattern =
"^(?:ISBN(-1(?:(0)|3))?:?\\ )?(?(1)(?(2)(?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})[- 0"
+ "-9X]{13}$)[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]|(?=[0-9]{13}$|(?=(?:[0-9]"
+ "+[- ]){4})[- 0-9]{17}$)97[89][- ]?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9])|("
+ "?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}$|97[89][0-9]{10}$|(?=(?:[0-9]+["
+ "- ]){4})[- 0-9]{17}$)(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X"
+ "])$";
@"^(?:ISBN(-1(?:(0)|3))?:?\ )?(?(1)(?(2)(?=[0-9X]{10}\z|(?=(?:[0-9]+[- ]){3})[- 0"
+ @"-9X]{13}\z)[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]|(?=[0-9]{13}\z|(?=(?:[0-9]"
+ @"+[- ]){4})[- 0-9]{17}\z)97[89][- ]?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9])|("
+ @"?=[0-9X]{10}\z|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}\z|97[89][0-9]{10}\z|(?=(?:[0-9]+["
+ @"- ]){4})[- 0-9]{17}\z)(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X"
+ @"])\z";

[GeneratedRegex(ValidationPattern, RegexOptions.IgnoreCase, DefaultRegexTimeoutInMs)]
private static partial Regex CreateRegex();
Expand Down
4 changes: 2 additions & 2 deletions src/HotChocolate/Core/src/Types.Scalars/LatitudeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private static class Latitude
private const int MaxPrecision = 8;

private const string SexagesimalRegex =
"^([0-9]{1,3})°\\s*([0-9]{1,3}(?:\\.(?:[0-9]{1,}))?)['′]\\s*(([0-9]{1,3}"
+ "(\\.([0-9]{1,}))?)[\"″]\\s*)?([NEOSW]?)$";
@"^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}"
+ @"(\.([0-9]{1,}))?)[""″]\s*)?([NEOSW]?)\z";

private static readonly Regex s_validationPattern =
new(SexagesimalRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase);
Expand Down
4 changes: 2 additions & 2 deletions src/HotChocolate/Core/src/Types.Scalars/LongitudeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private static class Longitude
private const int MaxPrecision = 8;

private const string SexagesimalRegex =
"^([0-9]{1,3})°\\s*([0-9]{1,3}(?:\\.(?:[0-9]{1,}))?)['′]\\s*(([0-9]{1,3}"
+ "(\\.([0-9]{1,}))?)[\"″]\\s*)?([NEOSW]?)$";
@"^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,}))?)['′]\s*(([0-9]{1,3}"
+ @"(\.([0-9]{1,}))?)[""″]\s*)?([NEOSW]?)\z";

private static readonly Regex s_validationPattern =
new(SexagesimalRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase);
Expand Down
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Types.Scalars/MacAddressType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MacAddressType : RegexType
{
private const string ValidationPattern =
@"^(?:[0-9A-Fa-f]{2}([:-]?)[0-9A-Fa-f]{2})(?:(?:\1|\.)(?:[0-9A-Fa-f]{2}([:-]?)"
+ "[0-9A-Fa-f]{2})){2,3}$";
+ @"[0-9A-Fa-f]{2})){2,3}\z";

#if BACKREFERENCE_NOT_SUPPORTED
[GeneratedRegex(_validationPattern, RegexOptions.None, DefaultRegexTimeoutInMs)]
Expand Down
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Types.Scalars/PhoneNumberType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class PhoneNumberType : RegexType
/// <summary>
/// Regex that validates the standard E.164 format
/// </summary>
private const string ValidationPattern = "^\\+[1-9][0-9]{2,14}$";
private const string ValidationPattern = @"^\+[1-9][0-9]{2,14}\z";

[GeneratedRegex(ValidationPattern, RegexOptions.None, DefaultRegexTimeoutInMs)]
private static partial Regex CreateRegex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public class StubType : RegexType
/// <summary>
/// Regex that validates the standard E.164 format
/// </summary>
private const string ValidationPattern = "^\\+[1-9][0-9]{2,14}$";
private const string ValidationPattern = @"^\+[1-9][0-9]{2,14}\z";

/// <summary>
/// Initializes a new instance of the <see cref="StubType"/>
Expand Down
Loading