You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
It's time to give the model validation support and overlook and see what parts needs overhauling. This issue will only track what is needed and what has been done. Each change should be logged as a different issue and tracked in here
Breaking Change Update DataAnnotations and FluentValidation packages so that they register all their required types using an application-registration. These packages should work without the use of the default bootstrapper auto-registration capabilities: See Validator registration improvements #1267
Remove the hard-coded factories of IDataAnnotationsValidatorAdapter and IFluentAdapter and make is so that they are registered using an application-registration and then resolved as ctor dependencies where ever they are required. This will make it easier to add custom validation rules. Add implementation -> automatically available -> super-duper-happy-path. See Data annotations improvements #1279 for Data Annotations changes and Fluent validation improvements #1305 for fluent validation changes
Breaking Change Look over ModelValidationResult.Errors and make it more user-friendly. It needs to have a good way to get a list of errors per field. This is to make it easier to connect it to a form etc. Possibly be able to return the data as Dictionary<string, IEnumerable<string>> where the string is the name of the property and the list is the validation error messages for that property. See Updated ModelValidationResult and ModelValidationError #1318
The DataAnnotations project is missing an DataAnnotationsValidatorAdapter implementation for the CompareAttribute. See comment Model validation overhaul #1265 (comment)
Breaking Change Revise the ModelValidationRule class and IDataAnnotationsValidatorAdapter.GetRules(ValidationAttribute attribute, PropertyDescriptor descriptor) implementations. The rules needs to be more friendly to consume from a client-side perspective. Something like a collection where the key is the member name and then a collection of applicable rules. The changes should be reflected on ModelValidationDescriptor and should probably be able to return something like Dictionary<string, IEnumerable<ModelValidationRule>>, where the string is the name of the property and the list contains the validation rules that should be enforced for that property. See Grouped validation rules per property #1314
Clean up the types in Nancy.Validation namespace. Make sure all types follow the code conventions and styles. Add missing XML comments to public types and members. See Nancy validation cleanup #1306
The text was updated successfully, but these errors were encountered:
With regards to the CompareAttribute, this is a 4.5 only attribute and there are a couple of others that was introduced in 4.5. Currently Nancy.Validation.DataAnnotations (and Nancy in general) target 4.0. What we (or perhaps someone in the community) could do is write a set of adapters for the 4.5-only attributes and publish those as separate package (like Nancy.Validation.DataAnnotations.Extensions)
Need to be able to bind to instances and to a list of instances if said instance/List is a property on the model. See #1263 to that shows a where binding to a property of a List fails. I've also tried to bind just a T instance and this also fails.
It's time to give the model validation support and overlook and see what parts needs overhauling. This issue will only track what is needed and what has been done. Each change should be logged as a different issue and tracked in here
DataAnnotations
andFluentValidation
packages so that they register all their required types using an application-registration. These packages should work without the use of the default bootstrapper auto-registration capabilities: See Validator registration improvements #1267IDataAnnotationsValidatorAdapter
andIFluentAdapter
and make is so that they are registered using an application-registration and then resolved as ctor dependencies where ever they are required. This will make it easier to add custom validation rules. Add implementation -> automatically available -> super-duper-happy-path. See Data annotations improvements #1279 for Data Annotations changes and Fluent validation improvements #1305 for fluent validation changesNancyContext
toIModelValidator.Validate(...)
to follow our "context everywhere"-ethos. See Passing NancyContext to IModelValidator.Validate #1311ModelValidationResult.Errors
and make it more user-friendly. It needs to have a good way to get a list of errors per field. This is to make it easier to connect it to a form etc. Possibly be able to return the data asDictionary<string, IEnumerable<string>>
where the string is the name of the property and the list is the validation error messages for that property. See Updated ModelValidationResult and ModelValidationError #1318DataAnnotations
project is missing anDataAnnotationsValidatorAdapter
implementation for theCompareAttribute
. See comment Model validation overhaul #1265 (comment)ModelValidationRule
class andIDataAnnotationsValidatorAdapter.GetRules(ValidationAttribute attribute, PropertyDescriptor descriptor)
implementations. The rules needs to be more friendly to consume from a client-side perspective. Something like a collection where the key is the member name and then a collection of applicable rules. The changes should be reflected onModelValidationDescriptor
and should probably be able to return something likeDictionary<string, IEnumerable<ModelValidationRule>>
, where the string is the name of the property and the list contains the validation rules that should be enforced for that property. See Grouped validation rules per property #1314Nancy.Validation
namespace. Make sure all types follow the code conventions and styles. Add missing XML comments to public types and members. See Nancy validation cleanup #1306The text was updated successfully, but these errors were encountered: