diff --git a/application/Espo/Classes/FieldValidators/Settings/ThousandSeparator/Valid.php b/application/Espo/Classes/FieldValidators/Settings/ThousandSeparator/Valid.php new file mode 100644 index 0000000000..ade7bb9ce6 --- /dev/null +++ b/application/Espo/Classes/FieldValidators/Settings/ThousandSeparator/Valid.php @@ -0,0 +1,60 @@ +. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +namespace Espo\Classes\FieldValidators\Settings\ThousandSeparator; + +use Espo\Core\FieldValidation\Validator; +use Espo\Core\FieldValidation\Validator\Data; +use Espo\Core\FieldValidation\Validator\Failure; +use Espo\ORM\Entity; + +/** + * @implements Validator + */ +class Valid implements Validator +{ + public function validate(Entity $entity, string $field, Data $data): ?Failure + { + $value = $entity->get($field); + + if (!$value) { + return null; + } + + if (!is_string($value)) { + return Failure::create(); + } + + if (preg_match('/^[0-9]$/', $value)) { + return Failure::create(); + } + + return null; + } +} diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index 543a0f8e13..577c47504c 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -31,6 +31,9 @@ ".", ",", "'" + ], + "validatorClassNameList": [ + "Espo\\Classes\\FieldValidators\\Settings\\ThousandSeparator\\Valid" ] }, "decimalMark": { diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index f0437d8b95..6723edf33a 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -155,6 +155,9 @@ ".", ",", "'" + ], + "validatorClassNameList": [ + "Espo\\Classes\\FieldValidators\\Settings\\ThousandSeparator\\Valid" ] }, "decimalMark": {