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
I have a potential resolution for this one as well but I thought it best to open some discussion first.
The current RuleSetForClientSideMessagesAttribute cannot be used with Razor Pages as it is an ActionFilter.
Option 1
Use a PageFilter which is added for all pages. This then checks for the presence of the RuleSetForClientSideMessagesAttribute and sets the value in HttpContext accordingly.
I have tested this it works fine. Quite neat actually and requires no changes to the current attribute. One possible issue is that it will call the filter for all pages unless the developer specifies which pages to run it for.
It could possibly be added in FluentValidationMvcExtensions via configuration.
Option 2
Add a new attribute e.g. PageModelRuleSetForClientSideMessagesAttribute which inherits ResultFilterAttribute and does the same thing as the RuleSetForClientSideMessagesAttribute.
This also passes tests and doesn't require any addition config. But of course requires a different attribute and can only be applied for the whole page and all handlers.
Conclusion
I think it might be worth implementing both and updating the documentation accordingly. If you would prefer only one or the other let me know and I will adjust before submitting the PR.
Also are you happy for me to to the docs update this time to save you having to do it?
And are you happy if I add some configuration options to the FluentValidationMvcExtensions to allow adding the page filter or would you prefer to just leave it to developers to add manually and just document it?
Best regards
Dave
The text was updated successfully, but these errors were encountered:
Hi Dave, I think I prefer option 1, so let’s go for that if you’d like to implement it. Let’s
enable it by default (in the RegisterServices method I think) - I’m not sure whether it really needs a config option to disable it, but let’s add one anyway.
Hi Jeremy,
I have a potential resolution for this one as well but I thought it best to open some discussion first.
The current
RuleSetForClientSideMessagesAttribute
cannot be used with Razor Pages as it is an ActionFilter.Option 1
Use a PageFilter which is added for all pages. This then checks for the presence of the
RuleSetForClientSideMessagesAttribute
and sets the value inHttpContext
accordingly.I have tested this it works fine. Quite neat actually and requires no changes to the current attribute. One possible issue is that it will call the filter for all pages unless the developer specifies which pages to run it for.
It could possibly be added in
FluentValidationMvcExtensions
via configuration.Option 2
Add a new attribute e.g.
PageModelRuleSetForClientSideMessagesAttribute
which inheritsResultFilterAttribute
and does the same thing as theRuleSetForClientSideMessagesAttribute
.This also passes tests and doesn't require any addition config. But of course requires a different attribute and can only be applied for the whole page and all handlers.
Conclusion
I think it might be worth implementing both and updating the documentation accordingly. If you would prefer only one or the other let me know and I will adjust before submitting the PR.
Also are you happy for me to to the docs update this time to save you having to do it?
And are you happy if I add some configuration options to the
FluentValidationMvcExtensions
to allow adding the page filter or would you prefer to just leave it to developers to add manually and just document it?Best regards
Dave
The text was updated successfully, but these errors were encountered: