-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
Description
Similar to how [Example("whatever")] can be used to show example values, an [AllowedValue("someValue")] attribute should be used to specify which values are allowed.
Could be simple like the one above - could also be more advanced as in:
[Parameter("n")]
[AllowedValue("a prime: 2, 3, 5, 7, ...", validator: typeof(PrimeChecker))]
public int N { get; set; }
where PrimeChecker could then be an IValidator:
public class PrimeChecker : IValidator
{
public void Validate(string value, Arguments accessToTheOtherArguments)
{
if (!ValueIsPrime(int.Parse(value))) {
throw new GoCommandoException($"Value '{value}' is not prime!");
}
}
}
Not sure yet what would work best. Could start out with the simple one.