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

Another validation question #35

Open
ghost opened this issue May 21, 2015 · 1 comment
Open

Another validation question #35

ghost opened this issue May 21, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented May 21, 2015

I've written a validation extension method using ICommandLineOptionFluent as the extensions key parameter, the method signature is as follows:

    public static void Validate<T>(this ICommandLineOptionFluent<T> value, Predicate<T> validate)
    {
        ...
        ...
        ...
    }

My question is how can I get the value to pass to the predicate, currently I see no way of doing this rendering the extension pointless. I was hoping to write something which I could contribute back.

As as an example of how I pictured this working:

        fluentCommandLineParser
            .Setup(arg => arg.Endpoints)
            .As('e', "endpoint")
            .Required()
            .Validate(addresses => addresses.All(address => address.IsAddress()));

Any advice?

Thanks,
Lee.

@siywilliams
Copy link
Member

Hi Lee,

You're unfortunately not going to get access to the guts that you want through the use of extensions methods, you'll have to mod the library itself.

I've just whipped up a rough commit with the bits that I think you would need. See the commit I've made in the new Issue-35 branch

I'm thinking the validation errors would be returned the same way as when values are unable to be parsed i.e through the result.Errors property.

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

No branches or pull requests

1 participant