Implement a function to parse and validate complex configuration files, and explain how you would handle syntax or structural errors.
Implement parse_and_validate(text, schema). Parse text as JSON, then validate it against the schema. A schema object maps required keys to rules, a one-element schema list validates every array item, and primitive rules are string, number, boolean, object, and array. Return (config, []) for valid input, or (None, errors) for invalid syntax or validation errors. Each error must contain path and message, using JSON-style paths such as $.server.ports[1].
text is a JSON string.schema is a nested dictionary, a one-element list schema, or a supported primitive rule.string, number, boolean, object, and array.def parse_and_validate(text, schema):