ValidateEnumValueAttribute.IsValid Method

Determines if the argument's value is defined.

Definition

Namespace: Ookii.CommandLine.Validation
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.1.0+9df03b6173b5fc9d44dc39638758964dd7a0f4c7
C#
public override bool IsValid(
	CommandLineArgument argument,
	Object? value
)

Parameters

argument  CommandLineArgument
The argument being validated.
value  Object
The argument value. If not null, this must be a string or an instance of CommandLineArgument.ArgumentType.

Return Value

Boolean
true if the value is valid; otherwise, false.

Remarks

If the Mode property is ValidationMode.BeforeConversion, the value parameter will be the raw string value provided by the user on the command line.

If the Mode property is ValidationMode.AfterConversion, for regular arguments, the value parameter will be identical to the CommandLineArgument.Value property. For multi-value or dictionary arguments, the value parameter will be equal to the last value added to the collection or dictionary.

If the Mode property is ValidationMode.AfterParsing, value will always be null. Use the CommandLineArgument.Value property instead.

If you need to check the type of the argument, use the CommandLineArgument.ElementType property unless you want to get the collection type for a multi-value or dictionary argument.

Exceptions

NotSupportedExceptionargument is not an argument with an enumeration type.

See Also