Class ValidationExtensions
Extension methods for adding validation rules to options and arguments.
Inheritance
System.Object
ValidationExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: McMaster.Extensions.CommandLineUtils
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
public static class ValidationExtensions
Methods
| Improve this Doc View SourceIsRequired(CommandArgument, Boolean, String)
Indicates the argument is required.
Declaration
public static CommandArgument IsRequired(this CommandArgument argument, bool allowEmptyStrings = false, string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
CommandArgument | argument | The argument. |
System.Boolean | allowEmptyStrings | Indicates whether an empty string is allowed. |
System.String | errorMessage | The custom error message to display. See also System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessage. |
Returns
Type | Description |
---|---|
CommandArgument | The argument. |
IsRequired(CommandOption, Boolean, String)
Indicates the option is required.
Declaration
public static CommandOption IsRequired(this CommandOption option, bool allowEmptyStrings = false, string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
CommandOption | option | The option. |
System.Boolean | allowEmptyStrings | Indicates whether an empty string is allowed. |
System.String | errorMessage | The custom error message to display. See also System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessage. |
Returns
Type | Description |
---|---|
CommandOption | The option. |