fix: Attribute values that are too long for mysql text fields don't generate warnings and just truncate, fixes #3196

added validation error
pull/3233/head
iglocska 2018-05-01 01:28:05 +02:00
parent 6740165cf1
commit 47df2d5c61
1 changed files with 10 additions and 0 deletions

View File

@ -420,6 +420,9 @@ class Attribute extends AppModel {
'validComposite' => array(
'rule' => array('validComposite'),
'message' => 'Composite type found but the value not in the composite (value1|value2) format.'
),
'maxTextLength' => array(
'rule' => array('maxTextLength')
)
),
'to_ids' => array(
@ -734,6 +737,13 @@ class Attribute extends AppModel {
return true;
}
public function maxTextLength($fields) {
if (strlen($fields['value']) > 65535) {
return 'The entered string is too long and would get truncated. Please consider adding the data as an attachment instead';
}
return true;
}
public function validCategory($fields) {
$validCategories = array_keys($this->categoryDefinitions);
if (in_array($fields['category'], $validCategories)) return true;