Sanitize form input

We have a text field that we’d like to include in one of our forms. Is there an ‘approved’ OOD way to sanitize that input so that it would be safe to use in, say, script.sh.erb?

Is there a Ruby library to do this installed as part of OOD?

Thanks!

You could use ruby’s regex like /the_regex/.match?(user_input) which will return true or false if it matches.

But I’d probably recommend html5 regular expressions which will check user input right off the bat without even submitting the job and having to check the output (and is accessible besides).

Let me know if that fits your use case or feel free to describe the use case a little more and I can help you figure out what may be the best pattern to use.

We would like to extend the form.yml with the ability to adopt some form of the validations made available to Rails models. Until then, in script.sh.erb at the top of the file you can have erb to validate the value specified and raise an exception if the value is not valid. The exception message will be relayed back to the user in the form of a red bootstrap alert message so they can correct the problem in the web form.