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
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.
The text was updated successfully, but these errors were encountered:
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:
where
PrimeChecker
could then be anIValidator
:Not sure yet what would work best. Could start out with the simple one.
The text was updated successfully, but these errors were encountered: