Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

AttemptedValueIsInvalidAccessor on nullable types results in "Nullable`1." message #6076

@ashleydw

Description

@ashleydw

Given the following where MyEnum is an optional value, where the default is null:

public async Task<IEnumerable<object>> DoSomethingAsync(MyEnum? myE)
{
// do something
// e.g. if(myE == null) {}  else {}
}

public enum MyEnum
{
   MyValOne = 0,
   MyValTwo = 1
}

And providing the query string with an invalid value (e.g. ?myE=asd) the request will fail via the ModelBindingMessageProvider and AttemptedValueIsInvalidAccessor; where the message is The value '{0}' is not valid for {1}..

However, with a nullable type, the {1} results in the message:

`The value 'asd' is not valid for Nullable`1.

I see a work around using localisation on the message, but should the message not attempt to find the underlying Type rather than the nullable?

Is this loosely related to #2985?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions