Class SqlConventionsValidator
Validator for SQL conventions.
This validator validates a single field named symbol
. Additional validation context
can be passed via providers.
For instance, if you're validating an index name, you might want to pass table
and type
:
$validator = new SqlConventionsValidator(); $validator->setProvider('table', 'my_table_name'); $validator->setProvider('type', 'index'); $symbol = 'my_index_name'; $errors = $validator->validate(compact('symbol'));
Validating a column can be achieved in a similar way. Also, allColumns
provider can be a list of
columns and the table they were first found in.
$validator = new SqlConventionsValidator(); $validator->setProvider('table', 'my_table_name'); $validator->setProvider('allColumns', ['my_column' => 'table_one', 'my_other_column' => 'table_two']); $symbol = 'my_column_name'; $errors = $validator->validate(compact('symbol'));
- Cake\Validation\Validator
-
BEdita\Core\Model\Validation\SqlConventionsValidator
Namespace: BEdita\Core\Model\Validation
Since: 4.0.0
Located at Core/src/Model/Validation/SqlConventionsValidator.php
Since: 4.0.0
Located at Core/src/Model/Validation/SqlConventionsValidator.php
Methods summary
protected static
array
|
|
protected static
string
|
|
protected static
string
|
|
public static
boolean
|
|
public static
boolean
|
|
public static
boolean
|
|
public static
boolean
|
|
public static
boolean
|
|
public static
boolean
|
|
public static
boolean
|
|
public static
boolean
|
#
differentFromTable( string $symbol, array $context )
Chech that a symbol does not match table name. |
public static
boolean|string
|
|
public static
boolean|string
|
|
public static
boolean
|
#
uniqueIdentifier( string $symbol, array $context )
Check that a symbol has a custom identifier between prefix and suffix. |
public static
boolean|string
|
|
public
|
Constants summary
string |
ALLOWED_RESERVED_WORDS
Comma-separated list of reserved words to be allowed anyway. |
#
'NAME,STATUS'
|
string |
ALLOWED_DUPLICATES
Comma-separated list of columns that can be duplicated across several tables. |
#
'created,core_type,description,enabled,expires,id,label,modified,name,params,priority,uuid,tree_left,tree_right,lang,status,created_by,modified_by,url'
|
Properties summary
protected static
array
|
$reservedWords
List of reserved words. |
#
[]
|