Commit Graph

50 Commits

Author SHA1 Message Date
Pranav K fb57810f29 Shortcircuit validation when using default validator providers and no validation metadata is discovered
Fixes https://github.com/aspnet/Mvc/issues/5887
2018-10-12 14:47:06 -07:00
Simon Cropp 43d4416a1d Fix typos (#8413) 2018-09-12 09:34:45 -07:00
Pranav K 522006d2c8
[Design] Add a MaxValidationDepth option to ValidationVisitor
Fixes #7357
2018-08-16 15:01:18 -07:00
Alexej Timonin d4beab5d09
CompositeValidationAttribute
- Add abstract CompositeValidationAttribute.
- Change DataAnnotationsMetadataProvider.CreateValidationMetadata to
populate ValidatorMetadata with validation attributes from CompositeValidationAttribute.
2018-07-20 15:31:14 -07:00
Pranav K 335500ab0e Use ModelMetadata from actual types for validation
Fixes https://github.com/aspnet/Mvc/issues/7952
2018-07-02 11:23:16 -07:00
Pranav K 624a5ed522 Fix ActionMethodExecutor incorrectly setting DeclaredType on ObjectResult
Fixes #7782
2018-05-18 10:43:28 -07:00
Steve Sanderson d9825d1547 Better JSON deserialization errors. Implements #4607, #4862 2017-11-06 23:02:13 +00:00
Steve Sanderson 236ef5d1d1 Support validation and BindBehavior on top-level action parameters and bound properties. Fixes #6790 2017-09-22 10:13:48 +01:00
bchavez 16c267d95e House Cleaning - Spelling and grammar 🚿 2017-08-30 14:58:44 -07:00
Kiran Challa 68866f8716 Added functional tests for JsonPatch 2017-04-23 09:09:08 -07:00
Steve Sanderson 90acd055fe Make [FromBody] treat empty request bodies as invalid (#4750) 2017-04-10 16:55:14 +01:00
Kiran Challa 8ac6b6699f [Fixes #4945] Simple string returned by controller action is not a valid JSON! 2017-01-25 13:29:18 -08:00
Doug Bunting d8d2e54506 Remove extra options to manipulate `JsonSerializerSettings`
- #4339: remove non-recommended JSON formatter constructors
 - affects `JsonInputFormatter`, `JsonOutputFormatter`, `JsonPatchInputFormatter`
 - `JsonOutputFormatter` cleanup also impacts `JsonHelper`
 - rename and make `SerializerSettingsProvider` class public; use it as appropriate
- #4409: make `SerializerSetings` properties get-only and `protected`
 - affects `JsonInputFormatter`, `JsonOutputFormatter`

Recommended patterns:
- change `JsonSerializerSettings` values in `MvcJsonOptions` for almost all customizations
- find `JsonOutputFormatter` in `MvcOptions.OutputFormatters` when limiting per-result formatters
- start with `JsonSerializerSettingsProvider.CreateSerializerSettings()` when customizing a per-result formatter
2016-04-27 14:48:16 -07:00
Kiran Challa fd3ee49987 [Fixes #4085] Controller helper inconsistency: HttpNotFound(), Ok() 2016-02-19 09:25:04 -08:00
jacalvar 7cbb263edb [Fixes #3874] Null passed as arguments to controller method parameters when no InputFormatter matches
* Add an UnsupportedContentType to the ModelState dictionary when no formatter can read the body.
* Add a filter to the pipeline that searches for that specific exception and transforms the response into 415.
2016-01-28 15:46:17 -08:00
N. Taylor Mullen 3be7fbdf9f Rename AspNet 5 file contents.
See https://github.com/aspnet/Announcements/issues/144 for more information.
2016-01-22 12:18:33 -08:00
Kiran Challa d77655fb73 MVC Controller Response - Wrong ContentType #3245 2015-12-21 11:25:45 -08:00
Ryan Nowak 8682fe0cfd Replace ActionBindingContext with ControllerContext
This change introduces ControllerContext for inside of Controllers, and
controller-specific extensibility points. ControllerContext carries with
it the model binding infrastructure needed to do all of the things that
controllers need to do.
2015-11-20 15:32:37 -08:00
Ryan Nowak 046cb976b3 Move ActionResult classes back to main namespace 2015-09-16 21:42:31 -07:00
Ryan Nowak 229724c4ea Reorganize MVC namespaces 2015-09-01 22:28:33 -07:00
Ryan Nowak ccb2f2deda React to move of StatusCodes 2015-07-08 12:43:33 -07:00
Ryan Nowak e985fa5d42 Split up MVC.Extensions into smaller packages
Startup.cs API experience to follow in a separate change. This change just
gets the bulk of the code churn out of the way.
2015-07-06 23:41:22 -07:00
Doug Bunting c4fa402105 Add `ModelBindingResult.IsFatalError` and make body binding more consistent
- part I of II for #2445 (with a duplicate code PR to follow)
- needed for #2445 because new `ModelState` entries for values will make inconsisteny worse
- change `BodyModelBinder` to use same keys for all `ModelBindingResult`s and `ModelState` entries
 - return fatal error result if formatter adds an error to `ModelState`
 - update potential callers to avoid avoid ignoring `IsFatalError`
- fix test attempting to serialize all of `ModelState`
 - will be borked with additional `RawValue`s in state
- fix two other tests that serialized `ModelState` but checked only `IsValid`

nits:
- address minor inconsistencies in `ModelBindingContext`
- use `System.Reflection.Extensions` package a bit more, where it's already referenced
- remove some unused resources
2015-06-18 16:19:01 -07:00
Harsh Gupta d0927bdc75 Fixes #2464 - Does not add extra skipped entries for model bound from services.
Also ensures that when a type is marked as skipped, any sub property which is model bound (and hence a modelstate un validated entry),
is marked as skipped (otherwise it would cause the ModelState to be invalid).
Also fixing a bug in model state dictionary FindKeyWithPrefix was not considering [0] & [0][0] as a valid prefix.
2015-05-15 12:27:43 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Pranav K 43e24b2aad Removing IInputFormatterSelector
Follow up work item to #2269
2015-04-08 07:35:48 -07:00
Kirthi Krishnamraju 2b246e7acc Fix for #1694 issue : Removed prefix for ModelState keys for FromBody parameters 2015-03-20 10:41:06 -07:00
Ajay Bhargav Baaskaran 13e1c9d5e1 added InputFormatter base type 2015-02-11 16:48:56 -08:00
Ajay Bhargav Baaskaran ac6a1a6a80 Replaced status code number with constants 2015-02-05 16:43:59 -08:00
Yishai Galatzer 5a3863d562 Implement StreamOutputFormatter
Include Functional tests and unit tests

Resolves #1653
2015-02-04 16:04:02 -08:00
Kiran Challa e5176d22f6 [Fixes #1121,#1508] Wrap objects for serialization/deserialization and DelegatingEnumerable<> support for IEnumerable<T> and IQueryable<T> 2015-01-30 18:10:01 -08:00
Kirthi Krishnamraju cbed666cba Added functionaltests for ModelMetadataType attribute and moved TryValidateModel tests actions to ValidationWebSite 2015-01-27 15:56:49 -08:00
Kiran Challa 5c2dc5db11 [Fixes#1792]Separate XML serializers to Microsoft.AspNet.Mvc.Xml 2015-01-22 15:09:20 -08:00
Kirthi Krishnamraju e41e5066f9 Added support for TryValidateModel and its corresponding tests 2015-01-16 17:23:59 -08:00
Kiran Challa 02f4ca9f05 [Fixes #1791]Remove XML formatter from defaults 2015-01-15 15:46:49 -08:00
Kiran Challa 00b61ec1e6 [Partial fix for #1372]Added SimpleTypesExcludeFilter to exlcude validation on simple types and also added tests to cover scenarios. 2014-12-03 14:09:51 -08:00
Doug Bunting 7eb106676c Add missing license headers
- #EngineeringDay
- license present but incorrect in just a few files
- skip generated files such as Resources.Designer.cs and files under
  test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
2014-11-20 22:54:05 -08:00
Doug Bunting 315908af5f Apply VS' FormatDocument and RemoveAndSort to all *.cs files
- #EngineeringDay
- VS does not yet format auto-properties nicely; reverted what it did

Also revert changes under
- test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles
2014-11-20 21:15:46 -08:00
Doug Bunting 5e067cdb9e Delete trailing whitespace
- #EngineeringDay
- Total replaced: 660  Matching files: 270 in *.cs
- Total replaced: 250  Matching files: 32 in all other files
- Total replaced: 22  Matching files: 8 in a few stragglers

Did not change files under following directories
- test\Microsoft.AspNet.Mvc.Razor.Host.Test\TestFiles\Output
- test\Microsoft.AspNet.Mvc.FunctionalTests\compiler\resources
- test\WebSites\TagHelpersWebSite
(Razor generates trailing whitespace in a case or two)
2014-11-20 16:18:09 -08:00
Ajay Bhargav Baaskaran 232deb47d0 added tests for json input formatter 2014-11-12 10:50:55 -08:00
Harsh Gupta 6b2f331e8d Adding support for excluding types for validation, based on type names for body bound models. 2014-11-06 11:00:50 -08:00
sornaks 53379e4395 Issue #1206 - DefaultBodyModelValidator throws if get accessor throws.
Fix: The MvcOptions takes in a list of ExcludeFromValidationDelegate (Func<Type,bool>). This func verifies if the type is excluded in validation or not.
2014-10-16 16:09:30 -07:00
Kiran Challa e985c22528 [Fixes #1216] Provide a property on JsonOutputFormatter to set serializer settings
[Fixes #1221] Rename OutputFormatter's WriteResponseContentHeaders to WriteResponseHeaders
[Fixes #932] Setting Json Serializer Settings
2014-10-15 09:27:09 -07:00
sornaks f1c1549267 Issue #452: Changes to enable validation for objects generated by InputFormatters. UnitTests + FunctionalTests for the same. 2014-10-06 16:29:56 -07:00
sornaks 4c951cc635 Issue #1081 - XML DataContract Formatter can fail to write when instance type != declaredType.
Adding Functional tests appropriately.
2014-09-19 15:01:49 -07:00
harshgMSFT 313a537ea1 Adding ModelStateError if there is no input formatter selected. 2014-08-22 16:52:58 -07:00
sornaks b9f1586008 Changes to introduce CanWriteResult for Xml OutputFormatters. 2014-08-20 11:09:09 -07:00
harshgMSFT 64d797a489 1. Moving input formatting related classes to MVC Core.(for tests as well).
2. Cleaning up the IInputFormatter to the final version.
3. Updating the input formatters and the context to be compliant with the IInputFormatter interface.
4. Adding Functional Tests.
- Not cleaning up TempInputFormatterProvider.

Conflicts:
	src/Microsoft.AspNet.Mvc.Core/Formatters/InputFormatter.cs
	src/Microsoft.AspNet.Mvc.Core/Formatters/JsonInputFormatter.cs
	src/Microsoft.AspNet.Mvc.Core/Formatters/TempInputFormatterProvider.cs
	src/Microsoft.AspNet.Mvc.Core/Formatters/XmlDataContractSerializerInputFormatter.cs
	src/Microsoft.AspNet.Mvc.Core/Formatters/XmlSerializerInputFormatter.cs
	src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
	src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs
	src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj
	test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj

Conflicts:
	src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
	src/Microsoft.AspNet.Mvc.HeaderValueAbstractions/Microsoft.AspNet.Mvc.HeaderValueAbstractions.kproj
	src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj
	src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/FormValueProviderFactory.cs
	test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj
	test/Microsoft.AspNet.Mvc.ModelBinding.Test/Microsoft.AspNet.Mvc.ModelBinding.Test.kproj

Conflicts:
	src/Microsoft.AspNet.Mvc.Core/Formatters/FormattingUtilities.cs
	src/Microsoft.AspNet.Mvc.Core/Formatters/TempInputFormatterProvider.cs
2014-08-18 17:07:19 -07:00
sornaks 2920c55116 Changes to enable XML Output Formatters.
- Unit / Functional tests for the same.
2014-08-15 15:05:00 -07:00
sornaks cee73c0af3 1. Introducing XML Input Formatters.
2. Adding DelegatingStream class
3. Unit + Functional tests for formatters.
2014-07-29 15:04:23 -07:00