validateSchema method
Validates that schema has the required sections and config.
Requires api, api.methods, response, and config, with exactly one
of config.bloc or config.riverpod set to true.
Validation errors are reported via CommandHelper to ensure consistent CLI output.
Implementation
bool validateSchema(Schema schema) {
if (schema.api == null) {
CommandHelper().error('Schema is not valid. "api" is required.');
return false;
}
if (schema.api?.methods == null) {
CommandHelper().error('Schema is not valid. "api.methods" is required.');
return false;
}
if (schema.response == null) {
CommandHelper().error('Schema is not valid. "response" is required.');
return false;
}
if (schema.config == null) {
CommandHelper().error('Schema is not valid. "config" is required.');
return false;
}
if (schema.config!.bloc == null && schema.config!.riverpod == null) {
CommandHelper().error('Schema is not valid. "config.bloc" or "config.riverpod" is required.');
return false;
}
return true;
}