The ValidatedConfig class builds on ConfigFile to provide a representation of a config file which has defined rules around the structure and data.
Create with API
Create from file
valuesFirst() to return the first (and maybe only) value at a specified address, will return undef if not-set. =values()= returns all entries as an array reference.
valuesMap() method returns a hash ref of all children, given the address of a group. Values are always returned as arrays, even if only a single value is allowed.
valuesMap("") will return the whole config structure as a hash.
valuesMapFlat() returns a single level hash with the full address as the key.
valuesSet() will set all values at the specified address.
The registry hash defines the allowed structure and data values. The first level of the hash represents the first level of the file.
The address of the
name attribute is simply
The format allows for hierarchical groupings.
To get all of the IP values for the
peers the address is
peers//ip (note the double slash).
Some groups may have names (known as a key). The
key attribute can be never, always or optional.
The address for the users who can read the private share is
The format attribute determines how the input value is parsed. If the input cannot be parsed as the stated format the configuration is invalid.
0 or 1
Attempts to parse as boolean, e.g. true, false, yes, no, 1, 0
A directory, will always tag as a directory regardless of trailing slash
A date with optional time
A filepath, may be tagged as a file location or directory location depending on input string
An integer, positive or negative
An integer or real number
Simple string reading, no special requirements. Default
Arrayref of values that are allowed
Arrayref of permissable keys for groups
Maximum number of values that can be set. "unlimited" means no limit. Default is 1
At least this many values must be set. So setting to 1 means that a value is required. Default is 0
For values the
default attribute provides values that will be set unless overriding by the file or API. The value can be a scalar or an array ref. If any value is a code reference that will be executed and the values added to the defaults.
For groups the default specifies which keys will be generated by default. Note that values in a group will only be defaulted if the group itself exists.
In some files you may not care about the named groups feature and just want a simple nested file. In this case you can just create a default group of "".
Was any default value used
Filename passed into constructor
First value at address
All values at address
Map of all values at address and below
Flattened map of all values at address and below
bool valuesSet(address, values)
Set/replace all values at address. Will return false on address/validation error
Write file. Will return false on validation error