-
Notifications
You must be signed in to change notification settings - Fork 581
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
(MODULES-560) Add new functions validate_numeric() and validate_integer(). #375
(MODULES-560) Add new functions validate_numeric() and validate_integer(). #375
Conversation
|
👍 I was just browsing the module's documentation looking for a validate_int(eger) function :) ! |
|
I missed to write an acceptance test. Will do so later and push it. |
|
With the future parse and types in the next version, what is this accomplishing that you can't with validate_re and a regex like '^-?\d+.?\d$' |
|
/cc @hlindberg |
|
With the new type system in Puppet 4.0 (and in future parser in 3.x) there is support for checking not only type but also the values of types. As an example, for integers (and floats) the type can be expressed as a range and the type can be combined with Optional (if an undef value is acceptable). Further you can use the scanf function to convert string representations to values (and handle failure). Types can be combined to express things like - Array of integers in a range etc. Type checking is automatic if parameter are declared with type, and there is an assert_type function that can be used for manual type checking. IMO we already have far too many "is_xxx" and "validate_xxx" functions in standard lib and we are about to deprecate and update these functions for puppet 4. Suggest sharing this validate_numeric function in a separate module for older puppet versions. |
|
Right, didn't have the new Puppet 4 stuff on the radar, but wanted to be able to do things now, still using Puppet 3.x Is there already such a module like you suggested? This seems to be a good plan... |
|
There is no such module (collection of 3x, new, but soon to be deprecated functions) - suggest you create your own. |
…eger_and_numeric (MODULES-560) Add new functions validate_numeric() and validate_integer().
|
I had a knee-jerk reaction and posted something that was not right. I deleted that comment. Sorry about the noise, should have read more carefully. |
|
Ego te absolvo. Thanks for merging! |
I saw MODULES-560 on Jira (https://tickets.puppetlabs.com/browse/MODULES-560) and had a need for it (check ports easily in a manifest), so I implemented it.
Added rspec unit tests, too.
Added necessary stuff to README.markdown, too.
Would be glad, if this gets merged... :) Thanks!