project BLF > class Database Component > method ValCharForbiddenCharCodes
validation procedure
Description
Validation mask to check if a certain field contains any characters commonly used as field separator, like pipe(|) or comma(,), and return an error if it does.
Parameters
icTargetField | input | character | Value of the business field to validate. |
icTargetFieldName | input | character | Name of the business field to validate. |
icRowid | input | character | Contents of field tc_Rowid, if the target field is a field of a component temp-table. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
QadFinancials
program code (program1/database.p)
if index(icTargetField,chr(2)) <> 0 or
index(icTargetField,chr(3)) <> 0 or
index(icTargetField,chr(4)) <> 0 or
index(icTargetField,chr(8)) <> 0 or
index(icTargetField,"|":U) <> 0 or
index(icTargetField,",":U) <> 0
then do:
assign oiReturnStatus = -1
vcMessageString = trim(#T-1'Code-fields (&1) cannot contain a comma, a pipe or any unprintable character.':255(5133)T-1#).
if index(icTargetField,chr(2)) <> 0
then assign vcMessageString = vcMessageString + chr(10) + trim(substitute(#T-2'This field contains the unpritable character number &1.':255(5134)T-2#,"2":U)).
if index(icTargetField,chr(3)) <> 0
then assign vcMessageString = vcMessageString + chr(10) + trim(substitute(#T-3'This field contains the unpritable character number &1.':255(5134)T-3#,"3":U)).
if index(icTargetField,chr(4)) <> 0
then assign vcMessageString = vcMessageString + chr(10) + trim(substitute(#T-4'This field contains the unpritable character number &1.':255(5134)T-4#,"4":U)).
if index(icTargetField,chr(8)) <> 0
then assign vcMessageString = vcMessageString + chr(10) + trim(substitute(#T-5'This field contains the unpritable character number &1.':255(5134)T-5#,"8":U)).
if index(icTargetField,"|":U) <> 0
then assign vcMessageString = vcMessageString + chr(10) + trim(#T-6'This field contains a pipe.':255(5135)T-6#).
if index(icTargetField,",":U) <> 0
then assign vcMessageString = vcMessageString + chr(10) + trim(#T-7'This field contains a comma.':255(5136)T-7#).
<M-8 run SetMessage
(input vcMessageString (icMessage),
input '' (icArguments),
input icTargetFieldName (icFieldName),
input icTargetField (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input icRowid (icRowid),
input 'BLF-318':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in database>
end. /* if index ... */