Question about schema.lua in custom_plugins

Hey!
if i want to configure nested object like that

return {
    fields = {
        A = {
            required = false,
            type = "table",
            schema = {
                fields = {
                    X = { type = "array", required = true, func = check_for_value },
                    Y = { type = "string", required = true },
                    Z = { type = "boolean", required = false, default = false }
                }
            }
        }
    }
}

But i want that if A (required=false) is not given than the inner schema validation will not run
cause now if i dont put the ‘A’ field i still getting:

{
“config.A.X” : “X is required”,
“config.A.Y” : “Y is required”
“config.A” : [
“A.X is required”,
“A.Y is required”
],
}

And another question about schema.lua
where I can read more about self_check , questions like what is plugin_t, and is_update?

Thanks!

where I can read more about self_check , questions like what is plugin_t, and is_update?

Regarding having a non-required table containing required fields, that is currently not possible in the schema validation rules, because a table inherits the “requiredness” of its sub-table. Your use-case does make sense, though. I think it’s something we should support in the future evolution of plugin schemas.

Regarding self_check:

  • the second argument (often called plugin_t in plugins) is the table being validated. In case of sub-schemas, it is called with the parent table.
  • is_update is a boolean flag indicating whether the schema is validating data for an update operation. Unlike insert operations, updates may be partial, so the self-check function should not assume that all fields are present in plugin_t when is_update is true.