validate method

List<ValidationResult> validate(
  1. String commandName,
  2. Parameters args
)

Validates Parameters args for command specified by its name using defined schema. If validation schema is not defined than the methods returns no errors. It returns validation error if the command is not found.

  • commandName the name of the command for which the 'args' must be validated.
  • args the parameters (arguments) to validate. Returns an array of ValidationResults. If no command is found by the given name, then the returned array of ValidationResults will contain a single entry, whose type will be ValidationResultType.Error. See Command See Parameters See ValidationResult

Implementation

/// - [commandName]   the name of the command for which the 'args' must be validated.
/// - [args]          the parameters (arguments) to validate.
/// Returns             an array of ValidationResults. If no command is found by the given
///                      name, then the returned array of ValidationResults will contain a
///                      single entry, whose type will be ValidationResultType.Error.

/// See [Command]
/// See [Parameters]
/// See [ValidationResult]

List<ValidationResult> validate(String commandName, Parameters args) {
  var cref = findCommand(commandName);

  if (cref == null) {
    var result = <ValidationResult>[];
    result.add(ValidationResult(null, ValidationResultType.Error,
        'CMD_NOT_FOUND', 'Requested command does not exist', null, null));
    return result;
  }

  return cref.validate(args);
}