PCI Vault has a rule engine for transforming data on certain endpoints. This is very handy for sanitising input for the purpose of operating on the data later.
Each rule will have a list of one or more operations that are applied in the order that they have been specified in. Each operation must have an input field, an output field, and a name for specifying which operation to be applied. Some operations also have required or optional arguments to further control their behaviour.
noop
does nothing but can be used to copy a value from one field to another.
stringify
converts data of any type to a string.
substr
attempts to take a substring from a string. If taking the substring fails, the value is just copied.
Optional Fields:
start
: The index on which to start the substring (default is 0).end
: The index on which to end the substring (default is 0).Both start and end is 0-indexed,
but if the end index is 0, it will be changed to the length of the input field.
Negative indices will be subtracted from the length of the input.
E.g. for the string "012345", if start is -2, and end is 0. The substring will be "45".
parse_float
attempts to parse a float from a string. If the input value is not a string, or if parsing fails, the value is just copied.
convert_to_int
attempts to convert any input to an integer. If the input value is a string, the int will be parsed using the base specified. If the input value is a float, the fractional part will be discarded. If the input value is a boolean, true will resolve to 1 and false to 0. If conversion fails, the value is just copied.
Optional Fields:
base
: For strings, try to parse integers in the specified base (default is 10).replace
replaces all occurrences of the substr
argument with new_str
. Make new_str
an empty string to effectively remove all occurrences of substr
. If the input is not a string, the value is just copied.
Required Fields:
substr
: The substring to replace.new_str
: The replacement string.mask
masks the substring specified by start
and end
. If unspecified, start
and end
will default to 0 and the length of the input string, respectively. If the input is not a string, the value is just copied.
Optional Fields:
char
: The character to use for masking (default is *
).start
: The index on which to start the substring (default is 0).end
: The index on which to end the substring (default is 0).Both start and end is 0-indexed,
but if the end index is 0, it will be changed to the length of the input field.
Negative indices will be subtracted from the length of the input.
E.g. for the string "012345", if start is -2, and end is 0.
The masked output will be "0123**".