You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+55-7Lines changed: 55 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -712,46 +712,68 @@ See the [`assert_type()`](https://docs.puppetlabs.com/references/latest/function
712
712
713
713
#### `is_absolute_path`
714
714
715
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
716
+
715
717
Returns 'true' if the given path is absolute. *Type*: rvalue.
716
718
717
719
#### `is_array`
718
720
721
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
722
+
719
723
Returns 'true' if the variable passed to this function is an array. *Type*: rvalue.
720
724
721
725
#### `is_bool`
722
726
727
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
728
+
723
729
Returns 'true' if the variable passed to this function is a boolean. *Type*: rvalue.
724
730
725
731
#### `is_domain_name`
726
732
733
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
734
+
727
735
Returns 'true' if the string passed to this function is a syntactically correct domain name. *Type*: rvalue.
728
736
729
737
#### `is_float`
730
738
739
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
740
+
731
741
Returns 'true' if the variable passed to this function is a float. *Type*: rvalue.
732
742
733
743
#### `is_function_available`
734
744
745
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
746
+
735
747
Accepts a string as an argument and determines whether the Puppet runtime has access to a function by that name. It returns 'true' if the function exists, 'false' if not. *Type*: rvalue.
736
748
737
749
#### `is_hash`
738
750
751
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
752
+
739
753
Returns 'true' if the variable passed to this function is a hash. *Type*: rvalue.
740
754
741
755
#### `is_integer`
742
756
757
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
758
+
743
759
Returns 'true' if the variable returned to this string is an integer. *Type*: rvalue.
744
760
745
761
#### `is_ip_address`
746
762
763
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
764
+
747
765
Returns 'true' if the string passed to this function is a valid IP address. *Type*: rvalue.
748
766
749
767
#### `is_ipv6_address`
750
768
769
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
770
+
751
771
Returns 'true' if the string passed to this function is a valid IPv6 address. *Type*: rvalue.
752
772
753
773
#### `is_ipv4_address`
754
774
775
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
776
+
755
777
Returns 'true' if the string passed to this function is a valid IPv4 address. *Type*: rvalue.
756
778
757
779
#### `is_mac_address`
@@ -760,10 +782,14 @@ Returns 'true' if the string passed to this function is a valid MAC address. *Ty
760
782
761
783
#### `is_numeric`
762
784
785
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
786
+
763
787
Returns 'true' if the variable passed to this function is a number. *Type*: rvalue.
764
788
765
789
#### `is_string`
766
790
791
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
792
+
767
793
Returns 'true' if the variable passed to this function is a string. *Type*: rvalue.
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1308
+
1279
1309
Validates that all passed values are either true or false. Aborts catalog compilation if any value fails this check.
1280
1310
1281
1311
The following values will pass:
@@ -1316,6 +1346,8 @@ validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to va
1316
1346
1317
1347
#### `validate_hash`
1318
1348
1349
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1350
+
1319
1351
Validates that all passed values are hash data structures. Aborts catalog compilation if any value fails this check.
1320
1352
1321
1353
The following values will pass:
@@ -1338,6 +1370,8 @@ Validates that all passed values are hash data structures. Aborts catalog compil
1338
1370
1339
1371
#### `validate_integer`
1340
1372
1373
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1374
+
1341
1375
Validates that the first argument is an integer (or an array of integers). Aborts catalog compilation if any of the checks fail.
1342
1376
1343
1377
The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
@@ -1396,6 +1430,8 @@ Validates that the first argument is an integer (or an array of integers). Abort
1396
1430
1397
1431
#### `validate_ip_address`
1398
1432
1433
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1434
+
1399
1435
Validates that the argument is an IP address, regardless of it is an IPv4 or an IPv6
1400
1436
address. It also validates IP address with netmask. The argument must be given as a string.
1401
1437
@@ -1444,24 +1480,28 @@ validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."
1444
1480
1445
1481
This function supports updating modules from Puppet 3 style argument validation (using the stdlib `validate_*` functions) to Puppet 4 data types, without breaking functionality for those depending on Puppet 3 style validation.
1446
1482
1447
-
> Note: This function relies on internal APIs from Puppet 4.4.0 (PE 2016.1) onwards, and doesn't work on earlier versions.
1483
+
> Note: This function is compatible only with Puppet 4.4.0 (PE 2016.1) and later.
1448
1484
1449
1485
##### For module users
1450
1486
1451
-
If you are running Puppet 4and receiving deprecation warnings about`validate_*` functions, the `validate_legacy` function can help you find and resolve the deprecated code.
1487
+
If you are running Puppet 4, the `validate_legacy` function can help you find and resolve deprecated Puppet 3`validate_*` functions. These functions are deprecated as of stdlib version 4.13 and will be removed in a future version of stdlib.
1452
1488
1453
-
In Puppet 3, the `validate_*` functions were the only way to easily check the types of class and defined type arguments. Some of the functions provided additional helpers like [validate_numeric](#validate_numeric), which unintentionally allowed not only numbers, but also arrays of numbers. Puppet 4 allows much better defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html), without such unintentional effects. The `validate_legacy` function makes these differences visible and makes it easier to move to the clearer Puppet 4 syntax.
1489
+
Puppet 4 allows improved defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html). Data types avoid some of the problems with Puppet 3's `validate_*` functions, which could sometimes be inconsistent. For example, [validate_numeric](#validate_numeric) unintentionally allowed not only numbers, but also arrays of numbers or strings that looked like numbers.
1454
1490
1455
-
Depending on the current state of development of the modules you use and the data you feed those modules, you'll encounter different messages:
1491
+
If you run Puppet 4 and use modules with deprecated `validate_*` functions, you might encounter deprecation messages. The `validate_legacy` function makes these differences visible and makes it easier to move to the clearer Puppet 4 syntax.
1492
+
1493
+
The deprecation messages you get can vary, depending on the modules and data that you use. These deprecation messages appear by default only in Puppet 4:
1456
1494
1457
1495
*`Notice: Accepting previously invalid value for target type '<type>'`: This message is informational only. You're using values that are allowed by the new type, but would have been invalid by the old validation function.
1458
1496
*`Warning: This method is deprecated, please use the stdlib validate_legacy function`: The module has not yet upgraded to `validate_legacy`. Use the [deprecation](#deprecation) options to silence warnings for now, or submit a fix with the module's developer. See the information [for module developers](#for-module-developers) below for how to fix the issue.
1459
-
*`Warning: validate_legacy(<function>) expected <type> value, got <actual type>_`: Your code passes a value that was accepted by the Puppet 3style validation, but will not be accepted by the next version of the module. Most often, you can fix this by removing quotes from numbers or booleans.
1497
+
*`Warning: validate_legacy(<function>) expected <type> value, got <actual type>_`: Your code passes a value that was accepted by the Puppet 3-style validation, but will not be accepted by the next version of the module. Most often, you can fix this by removing quotes from numbers or booleans.
1460
1498
*`Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, validate_legacy(<function>) expected <type> value, got <actual type>`: Your code passes a value that is not acceptable to either the new or the old style validation.
1461
1499
1462
1500
##### For module developers
1463
1501
1464
-
Many `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics. In contrast, Puppet 4 [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html) allows you to choose between `Numeric`, `Array[Numeric]`, or `Optional[Numeric]`. The `validate_legacy` function helps you move from Puppet 3 style validation to Puppet 4 validation without breaking functionality your module's users depend on.
1502
+
The `validate_legacy` function helps you move from Puppet 3 style validation to Puppet 4 validation without breaking functionality your module's users depend on.
1503
+
1504
+
Moving to Puppet 4 type validation allows much better defined type checking using [data types](https://docs.puppet.com/puppet/latest/reference/lang_data.html). Many of Puppet 3's `validate_*` functions have surprising holes in their validation. For example, [validate_numeric](#validate_numeric) allows not only numbers, but also arrays of numbers or strings that look like numbers, without giving you any control over the specifics.
1465
1505
1466
1506
For each parameter of your classes and defined types, choose a new Puppet 4 data type to use. In most cases, the new data type allows a different set of values than the original `validate_*` function. The situation then looks like this:
1467
1507
@@ -1504,6 +1544,8 @@ Always note such changes in your CHANGELOG and README.
1504
1544
1505
1545
#### `validate_numeric`
1506
1546
1547
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1548
+
1507
1549
Validates that the first argument is a numeric value (or an array or string of numeric values). Aborts catalog compilation if any of the checks fail.
1508
1550
1509
1551
The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
@@ -1520,6 +1562,8 @@ Validates that the first argument is a numeric value (or an array or string of n
1520
1562
1521
1563
#### `validate_re`
1522
1564
1565
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1566
+
1523
1567
Performs simple validation of a string against one or more regular expressions. The first argument of this function should be the string to
1524
1568
test, and the second argument should be a stringified regular expression (without the // delimiters) or an array of regular expressions. If none of the regular expressions match the string passed in, compilation aborts with a parse error.
1525
1569
@@ -1554,6 +1598,8 @@ test, and the second argument should be a stringified regular expression (withou
1554
1598
1555
1599
#### `validate_slength`
1556
1600
1601
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1602
+
1557
1603
Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if the second argument is not convertable to a number. Optionally, a minimum string length can be given as the third argument.
1558
1604
1559
1605
The following values pass:
@@ -1576,6 +1622,8 @@ Validates that the first argument is a string (or an array of strings), and is l
1576
1622
1577
1623
#### `validate_string`
1578
1624
1625
+
**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validatelegacy).**
1626
+
1579
1627
Validates that all passed values are string data structures. Aborts catalog compilation if any value fails this check.
1580
1628
1581
1629
The following values pass:
@@ -1646,7 +1694,7 @@ Takes one element from first array given and merges corresponding elements from
1646
1694
1647
1695
As of Puppet Enterprise 3.7, the stdlib module is no longer included in PE. PE users should install the most recent release of stdlib for compatibility with Puppet modules.
0 commit comments