scripts.radconf.filters
RadConf filter chains
Start a chain with radconf.filter(value) or radconf.filter.variable(path).
Filters operate on the script's request and retain internal values between steps.
filter(value)
radconf.filter(value) starts a chain from a supplied value. Each filter step
returns a new chain; earlier chains keep their original values.
local normalized = radconf.filter("00:1A:2B:3C:4D:5E")
:normalize_mac()
:uppercase()
:value()
Extract results
Use :value() to extract zero or one result. No result returns nil; multiple
results raise an error. Use :values() to extract all results as a sequence:
local groups = radconf.filter("admin,reader")
:split(",")
:values()
radconf.set("user.group", groups)
See value conversions for multivalue sequences and their distinction from JSON arrays.
Filter methods and arguments
Filter names and arguments follow the RadConf filter reference.
Pass arguments using Lua literals. Strings, booleans, integers, JSON tables,
binary strings, and regular expressions produced by the regex filter are
supported as arguments.
Use a final options table for named password_hash options:
local hash = radconf.filter(password)
:password_hash("pbkdf2_sha256", {rounds = 300000})
:value()
:apply(name, ...) invokes a filter by name. Use :apply("value") for RadConf's
value conversion filter, because :value() is the extraction method:
local number = radconf.filter("42"):apply("value"):value()
Variable-backed chains
radconf.filter.variable(path) reads a RadConf accessor and retains its path.
Filtering does not modify the source. Call :assign() to replace the source with
the chain's result:
radconf.filter.variable("aaa.identity")
:lowercase()
:assign()
The chain captures its input when created. Assignment uses the retained path in the same request. Read-only targets reject assignment. Assigning multiple results to a scalar target raises an error instead of keeping only the first. Empty results clear the target where its RadConf setter supports clearing.
Literal chains have no source and reject :assign(). Map accessors cannot start
variable-backed chains; select a map entry instead.
Errors and recovery
Failed filters produce error values inside the chain. Later steps use their
RadConf semantics. Use :recover(fallback) to replace failed values, or
:default(fallback) to replace missing results:
local document = radconf.filter(input)
:json()
:recover({name = "unknown"})
:value()
:value(), :values(), and :assign() raise Lua errors if any result is still
an error. Unrecovered filter errors prevent assignment. Invalid filter names
and invalid filter arguments raise errors when the step is called; catch these
with Lua's pcall().
See variable access for direct reads and writes.