mark-pro / Genesis.MinimalApis

Genesis.MinimalApis aims to expand and create organization for Microsoft's Minimal APIs.
MIT License
1 stars 0 forks source link

Consider attribute usage for validation filtering #13

Closed mark-pro closed 1 year ago

mark-pro commented 1 year ago

Consider using or merging Genesis.MinimalApis.Validation with Genesis.MinimalApis so that Attributes might be used to provide FluentValidation filtering on parameters.

mark-pro commented 1 year ago

The idea presented would all for the use of an attribute to be used to indicate that the function should be validated with a FluentValidation.IValidator<T>.

Attribute could be named:

record Echo(string Message);

[Validate<Echo>]
[MapGet("api/echo")]
string echo([AsParameters] Echo e) => e.Message;
mark-pro commented 1 year ago

Final design for attribute usage; both are now applicable.


record Echo(string Message);

[ValidateParam(typeof(Message))]
[HttpGet("api/echo")]
string echo([AsParameters] Eche e) => e.Message
record Echo(string Message);

[HttpGet("api/echo")]
string echo([Validate, AsParameters] Eche e) => e.Message