Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input validation for XML launch files #731

Open
pac48 opened this issue Sep 10, 2023 · 1 comment
Open

Input validation for XML launch files #731

pac48 opened this issue Sep 10, 2023 · 1 comment
Labels
backlog enhancement New feature or request

Comments

@pac48
Copy link

pac48 commented Sep 10, 2023

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.

<arg name="robot_ip" default="127.0.0.1" regex="^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$"/>

A more elaborate solution could use dedicated tags for common validation types, e.g.

<arg name="robot_ip" default="127.0.0.1" validators="ip_address"/>
<arg name="web_server" default="http://127.0.0.1:8080" validators="url"/>
<arg name="dof" default="7" validators="one_of([6,7])"/>

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

@clalancette clalancette added enhancement New feature or request backlog labels Sep 21, 2023
@clalancette
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants