Subject: | Params::Validate could protect against typos in code accessing the params hash |
Params::Validate is very handy. It does a great job of validating the arguments.
With a simple change it could also do a great job of protecting against typos in code accessing
the params hash: add a lock_keys option to validation_options() that would call Hash::Util
lock_keys() on the hash ref returned when validate() is called in scalar context.
Then an error would be raised when any code accesses the parameter hash with an incorrect key
name.
p.s. Performance could be improved if users cached the hash ref passed to validate() instead of
recreating it each time. e.g., validate(@_, state $param_spec = { ... }); It would be handy if the
docs noted this and also noted if/when Params::Validate alters the hash (hopefully it doesn't).