-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/build error type response #12
Conversation
…name with Prefix and Type.
… make method GetErrorCodeWithPrefixRuleType static
Kudos, SonarCloud Quality Gate passed! |
/// <summary> | ||
/// Prefix used to override property name. | ||
/// </summary> | ||
public const string Prefix = "_RuleType"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: maybe I'm missing something here, but is this prefix really required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luizhlelis this prefix is important to set correctly type in response.
We only set type, if exists an internal ErrorCode with this prefix.
if (!string.IsNullOrEmpty(propertyName)) | ||
options.WithName(propertyName); | ||
|
||
options.WithErrorCode($"{RuleTypeConst.Prefix}.{type}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: we're gonna need to use the same extension method WithErrorCode
in #8, but I think we can use it in both scenarios. We can set some predefined words as ErrorCodes to change the response status code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice @luizhlelis, make sense.
We can use a new Enum.ErrorsStatusCode in this lib, creating a new method like "WithStatusCode(Enum.ErrorsStatusCode)".
We create other branch feature/customer-main, to follow this:
2 - Apply branch feature/customer-main in customer project; |
Summary
Create method WithRuleType in validation, to override property name with Prefix and Type.
How to use method WithRuleType in validation?
How property name stay?
Why use it?
To identify Rules in InvalidModelStateResponseFactory and customize the HTTP response.