Skip to content

Commit

Permalink
Reverting index name validation
Browse files Browse the repository at this point in the history
Closes #1017
  • Loading branch information
gmarz committed Nov 24, 2014
1 parent d1bc20d commit fe3105d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 99 deletions.
31 changes: 0 additions & 31 deletions src/Nest/DSL/CreateIndexDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,10 @@ public interface ICreateIndexRequest : IIndexPath<CreateIndexRequestParameters>

internal static class CreateIndexPathInfo
{
private static char[] _invalidChars = new[] { '\\', '/', '*', '?', '"', '<', '>', '|', ' ', ',', '#' };
private static string _invalidCharsMessage = string.Join(", ", _invalidChars);

public static void Update(ElasticsearchPathInfo<CreateIndexRequestParameters> pathInfo, ICreateIndexRequest request)
{
pathInfo.HttpMethod = PathInfoHttpMethod.POST;
}

public static void Validate(ElasticsearchPathInfo<CreateIndexRequestParameters> pathInfo, ICreateIndexRequest request)
{
var index = pathInfo.Index;
if (index.StartsWith("_"))
throw new DslException("indexname {0} may not start with an underscore".F(index));

if (Encoding.UTF8.GetByteCount(index) > 255)
throw new DslException("indexname {0} exceeds maximum index name length of 255".F(index));

if (index.Any(char.IsUpper))
throw new DslException("indexname {0} contains uppercase characters".F(index));

if (index.Any(c => _invalidChars.Contains(c)))
throw new DslException("indexname {0} contains one of {1} invalid characters".F(index, _invalidCharsMessage));

}
}

public partial class CreateIndexRequest : IndexPathBase<CreateIndexRequestParameters>, ICreateIndexRequest
Expand All @@ -53,11 +33,6 @@ protected override void UpdatePathInfo(IConnectionSettingsValues settings, Elast
{
CreateIndexPathInfo.Update(pathInfo, this);
}

protected override void ValidatePathInfo(ElasticsearchPathInfo<CreateIndexRequestParameters> pathInfo)
{
CreateIndexPathInfo.Validate(pathInfo, this);
}
}

[DescriptorFor("IndicesCreate")]
Expand Down Expand Up @@ -259,11 +234,5 @@ protected override void UpdatePathInfo(IConnectionSettingsValues settings, Elast
{
CreateIndexPathInfo.Update(pathInfo, this);
}

protected override void ValidatePathInfo(ElasticsearchPathInfo<CreateIndexRequestParameters> pathInfo)
{
CreateIndexPathInfo.Validate(pathInfo, this);
}

}
}
7 changes: 0 additions & 7 deletions src/Nest/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ internal static void ThrowIfEmpty<T>(this IEnumerable<T> @object, string paramet
throw new ArgumentException("Argument can not be an empty collection", parameterName);
}

internal static void ThrownIfNotLowercase(this string @object, string parameterName)
{
@object.ThrowIfNull(parameterName);
if (@object.Any(char.IsUpper))
throw new ArgumentException("Argument can not have uppercase letter", parameterName);
}

internal static IList<T> EagerConcat<T>(this IEnumerable<T> list, IEnumerable<T> other)
{
list = list.HasAny() ? list : Enumerable.Empty<T>();
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/Tests/Nest.Tests.Unit/Nest.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
<Compile Include="Internals\Inferno\EscapedFormatTests.cs" />
<Compile Include="Internals\Inferno\HostNameWithPathTests.cs" />
<Compile Include="Internals\Inferno\MapTypeNamesTests.cs" />
<Compile Include="Internals\Inferno\IndexNameResolverTests.cs" />
<Compile Include="Internals\Inferno\MapPropertyNamesForTests.cs" />
<Compile Include="Internals\Serialize\ConnectionSettingsTests.cs" />
<Compile Include="Internals\Serialize\NullValueHandlingTests.cs" />
Expand Down

0 comments on commit fe3105d

Please sign in to comment.