Validation

Spring Shell integrates with the Bean Validation API to support automatic and self-documenting constraints on command parameters.spring-doc.cn

Annotations found on command parameters and annotations at the method level are honored and trigger validation prior to the command executing. Consider the following command:spring-doc.cn

	@ShellMethod("Change password.")
	public String changePassword(@Size(min = 8, max = 40) String password) {
		return "Password successfully set to " + password;
	}

From the preceding example, you get the following behavior for free:spring-doc.cn

shell:>change-password hello
The following constraints were not met:
	--password string : size must be between 8 and 40 (You passed 'hello')