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

Integrating Bogus with FluentValidation's Rules #76

Closed
thiagomajesk opened this issue Jun 26, 2017 · 1 comment
Closed

Integrating Bogus with FluentValidation's Rules #76

thiagomajesk opened this issue Jun 26, 2017 · 1 comment

Comments

@thiagomajesk
Copy link

Hi! I see that Bogus is heavily inspired by FluentValidation's sintax. I wonder if it's possible to integrate Bogus directly wiht FluentValidation's rules and validators. I mean, if I already have an AbstractValidator, can I use Bogus to generate data respecting the rules/constraints of that validator? (This would spare so much time for anyone using FluentValidation and xUnit)

@thiagomajesk thiagomajesk changed the title Integrating Bogus with FluentValidations Rules Integrating Bogus with FluentValidation's Rules Jun 26, 2017
@bchavez
Copy link
Owner

bchavez commented Jun 27, 2017

Hello @thiagomajesk,

This sounds like a cool idea. Perhaps this could be done as a plugin or as an extension assembly Bogus.Plugin.FluentValidator. I think an extension assembly would be better at the moment so Bogus doesn't take a hard-dependency on FluentValidator.

Basically, to get something like this to work, you'll need to create some kind of AbstractValidator reader that translates FluentValidation's rules into Bogus rules. With FluentValildator's .With() and .Unless() and child/nested validators, I can imagine this reader-conversion could get very complex very fast; even with upcoming features like #8 and #74 that introduce "conventions".

I think it would take a decent amount of work to get your use-case operational. At the moment we won't have any immediate plans to do this. So, I'm going to close this issue for now.

If you feel strongly Bogus should have this feature, my suggestion would be to download the Bogus code, create a fork, or create a separate repo referencing Bogus and take a stab at implementing your feature. If you can come up with a rather complete solution, I'd be happy to take a look and possibly merge it into Bogus. I mean possibly because we'll have to weigh the benefits against the amount of complexity and maintainability that it may introduce. Additionally, if you find any pain points in extending Bogus, feel free to let me know; I'm pretty open to exposing Bogus' internal Faker<T> variables so you can extend it.

Thanks,
Brian

🔥 🌋 "We're building it up, to break it back down..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants