The SQL string to validate
The database schema definition
The dialect to use for parsing
Validation options
Validation result with schema-related errors
const schema: Schema = {
tables: [{
name: 'users',
columns: [
{ name: 'id', type: 'integer', primaryKey: true },
{ name: 'name', type: 'varchar' },
{ name: 'email', type: 'varchar' },
],
}],
};
const result = validateWithSchema(
'SELECT id, name, unknown_col FROM users',
schema,
'postgresql'
);
// result.errors will contain an error for unknown_col
Validate SQL against a database schema.