Commit Graph

8 Commits

Author SHA1 Message Date
Ryan Nowak 8a502dbe5d Rewrite of validation 2015-09-25 16:56:42 -07:00
Ryan Nowak a6aaef0d63 Optimize async code in model binders
Optimize the 'no-op' path for our model binders to return a cached task
where possible without going async.
2015-09-08 09:42:34 -07:00
Ryan Nowak 076ce6a8a1 Make ModelBindingResult a struct. 2015-09-03 12:52:50 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Ryan Nowak 2719111453 Add more details to ModelAttributes
This change adds more information to ModelAttributes, so that metadata
providers can look at the attributes on the property and type separately
if so desired
2015-04-17 17:35:20 -07:00
Ryan Nowak 90cef3b9ca Refactor of the model metadata provider
Separates the MMP into two phases:
1). Creation of the ModelMetadata, discovery of properties and attributes
(reflection) is part of the MMP
2). Lookup of details based on attributes is now part of another phase,
and has its results cached.

Users can now implements and register an IFooMetadataProvider to customize
a single aspect of metadata (see how data annotations does it).
2015-03-05 13:19:10 -08:00
Harsh Gupta f19c2e493d Merging Model Validation for body and non body validation.
This also fixes #1503.

Currently all model binders except mutable object binder are independent of validation code. The mutable object binder which needs to do some validation ( for scenarios involving [BindRequired] and [BindNever]).
We would be going with an approach where required validaiton happens in input formatters and model binders.
This is needed as validation for value types can best be done at creation time.

Followup PRs:
Introduce support for skipping validation (and not binding) for a particular property/type etc.
2015-02-17 11:50:39 -08:00
Ryan Nowak 12f8f23ccb Make BindingSource extensible
This is a major refactor of how IBinderMetadata interacts with model
binders and value providers. We're doing this to support better
extensibility for metadata in ApiExplorer.

You'll notice a bunch of deleted code in DefaultApiDescriptionProvider
that maps metadata marker interfaces to a fixed list of Api sources. This
is replaced now with IBindingSourceMetadata - which also replaces the
hierarchy of marker interfaces. Now user code can create an arbitrary
binding source and have a consistent API for model-binders,
value-providers and full-visibility in ApiExplorer as
well.

Additonally, there's some error checking in place that better enforces the
constraints we already have in the system. IE you can't create a 'greedy'
model binder that uses value-provider data.

Two additional enhancements are planned for followup PRs:
1. Add a BindingSource property to model-metadata. This will remove some
duplication, but I want to delay it because it would touch another 10 or
so files.

2. Add an extensibility interface for our 'special' model binders like the
file binder so these can show up in ApiExplorer as well.
2015-02-05 13:41:31 -08:00