Skip to content
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 Request] Add option to set RootContextData #183

Open
pokorsky opened this issue Feb 21, 2023 · 1 comment
Open

[Feature Request] Add option to set RootContextData #183

pokorsky opened this issue Feb 21, 2023 · 1 comment
Labels
Feature Request Request to add a new feature Triage Issue needs to be triaged

Comments

@pokorsky
Copy link

The FluentValidation allows to pass custom data as a dictionary to Validation call. It is possible by creating ValidationContext with RootContextData.

var person = new Person();
var context = new ValidationContext<Person>(person);
context.RootContextData["MyCustomData"] = "Test";
var validator = new PersonValidator();
validator.Validate(context);

The current FluentValidationValidator.Validate accepts only the options parameter. No way to pass the validation context.

I tried to build EditContext using ValidationContext but it did not work as EditContextFluentValidationExtensions.ValidateModel does not expect such an option and it always creates its own ValidationContext.

var context = new ValidationContext<Person>(person);
_editContext = new EditContext(context)

It would be great to extend API to allow to pass the ValidationContext the same way as validation options and support it in EditContextFluentValidationExtensions.ValidateModel.

Or did I miss something? Thanks

@pokorsky pokorsky added Feature Request Request to add a new feature Triage Issue needs to be triaged labels Feb 21, 2023
@yenhanshih
Copy link

There's an existing PR that seems to address this concern. This is waiting to be reviewed and merged in.

#156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request to add a new feature Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants