Open pac48 opened 12 months ago
We discussed this, and think that this is a good feature to have. Particularly the "validators" concept would be a very nice addition.
The place to start is probably to introduce the concept of a validator to the Python LaunchArgument
; then we can extend it from there to support XML and YAML.
That said, we probably won't work on this in the near future. I'll place it on the backlog but please feel free to work on it and open a pull request if you are interested in doing that.
Feature request
Feature description
One of the advantages of using Python-based launch files as opposed to XML is the ability to validate input arguments and parameters. For example, if the launch file allows the user to set the arg
robot_ip
, it should not accept a malformed address. Instead, it would be nice if it informed the user of the mistake. Other than catching typos, input validation could potentially catch dependency issues, such as missing plugins. I believe validating string types would provide the most benefit, such as IP address, plugin names, file paths, etc. but numerical types could also be validated by checking upper or lower bounds.In terms of implementation, there are several ways it can be expressed. The simplest solution is to add a regex tag that uses regex, e.g.
A more elaborate solution could use dedicated tags for common validation types, e.g.
I think there are other ways to achieve the same effect. I'm also interested in knowing how others might go about implementing it and what types of validations would provide the most value.
*credit to stackoverflow for IP regex