Skip to content

Validations Send source.pointer #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 8, 2018

Conversation

rtablada
Copy link
Contributor

@rtablada rtablada commented Aug 7, 2018

No description provided.

Copy link
Contributor

@jaredcnance jaredcnance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like there were any tests for ModelStateExtensions. If you have time to write them that would be awesome. Otherwise I'll grab it tonight.

@@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Extensions
{
public static class ModelStateExtensions
{
public static ErrorCollection ConvertToErrorCollection(this ModelStateDictionary modelState)
public static ErrorCollection ConvertToErrorCollection<T>(this ModelStateDictionary modelState, IContextGraph contextGraph)
Copy link
Contributor

@jaredcnance jaredcnance Aug 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, that we don't have to release this in a major version, let's leave the original implementation and deprecate it using the [Obsolete("Use the generic overload instead")]. This prevents us from breaking anyone that is calling this API directly.

Also, I've recently been leaning towards the idea of depending on the static ContextGraph.Instance rather than injecting everywhere. I haven't found many reasons the ContextGraph should change after app start. Thoughts? disregard, that's going to be too big of an issue to bite off right now (i.e. there will be broken tests)

Copy link
Contributor Author

@rtablada rtablada Aug 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 for ContextGraph.Instance I wonder if that's safe given possible different versions of the API running at once with different context graphs?

If ContextGraph.Instance is used other places that could still be an issue there, but IDK if we'd want to tie this down too?

@@ -16,10 +16,19 @@ public static ErrorCollection ConvertToErrorCollection(this ModelStateDictionary

foreach (var modelError in entry.Value.Errors)
{
var attrName =contextGraph.GetPublicAttributeName<T>(entry.Key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do this lookup outside this loop since entry.Key doesn't change...results in unnecessary enumerations of the graph

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jaredcnance jaredcnance merged commit f05b466 into json-api-dotnet:master Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants