Skip to content

Commit b42c1e1

Browse files
author
Jevgeny Fedorovich
committed
Fixes #1375 - enum values are also considered during validation
1 parent ef70951 commit b42c1e1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Microsoft.OData.Core/UriParser/Binders/MetadataBindingUtils.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,11 @@ internal static void VerifyCollectionNode(CollectionNode node, bool enableCaseIn
201201
{
202202
if (item != null && item.Value != null && item.Value is ODataEnumValue enumValue)
203203
{
204-
if (!enumType.ContainsMember(enumValue.Value, comparison))
205-
{
204+
if (!enumType.ContainsMember(enumValue.Value, comparison) &&
205+
(!long.TryParse(enumValue.Value, out var longValue) ||
206+
!enumType.TryParse(longValue, out var _))
207+
)
208+
{
206209
throw new ODataException(Error.Format(SRResources.Binder_IsNotValidEnumConstant, enumValue.Value));
207210
}
208211
}

0 commit comments

Comments
 (0)