
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 07:50 AM
Hi all,
Currently, it is not possible to use "Validation Regex" on a variable of type "Multi Line Text".
I regularly use this possibility with "Single Line Text".
Unable to do so, I want to develop a validation script after entering the value in the field.
The value to validate is an RSA key of private type.
And it should be written like this :
----- BEGIN RSA PRIVATE KEY -----
MIIEpQIBAAKCAhjfsyneysdKC + aTZbetCh + h8VxOBIB / yMKMAUwT5hkAoV0Jp5NSp
uOQf16ZE1e4LfupQDWTr1YlL3M / LTSkshgsPCp9yL6ysiJrNM6yIcpTQQn8xHCJQo
trK2refJhjnS0d9RBuQYhiO9itsfgEuFM2n7GoW3prxebVDWixQnyOAC / DpQd7bAT
9mo3QdB8ulqYVoefcP2P6yxU68zbu1G0xQEoBjSszGIeBZUUYSmqGHuXNrrGOi1v
ii6uZQ4sa5T6Zuh23aH1rjiCWJUrGjHhYdodHv4kXCp4tslDqoP47zqquzEa77yC
nc / wlDjCFQuuj + HeID4uUQnCTJTkvqfduB / 6gQIDAQABAoIBAQC2cgZklv3PV + 1W
T5k0PxtMnBbPi / oCOeAg72qqv0Wa3A3wVnJaWbcX7Iw6 + rcBNsPMThT15zKlV9or
P0Y / Ash12xd6YvPzS78UYzjM5Y3VcO7Q / DFz8LcNHsFKYvDGjiXFv + UZeztgPpGp
4bwPaA41iYX6cZtW1r5GMCBETudzigoe73E / RBpdRUN6jMreJDCdG / x + fjsDJK2o
SOZwiu2EKu9Cy5kMLqn1NcoxzngI0uujMQmei4j9s2xK9TKvEkoRe89rrzXDt0G6
/ QPH5ttAc1CX6VFR7KWroUwbxOoQ1TEidMX96gq8pUCOSTOqVpgX / QyA5aJUWaZX
biXI3MnBAoGBAPHZIig19h5Z0AbIDOL9HIl4IjXaO7rb0Y6vcpgdJQjgcxxsr4wc
Ud2C6PNskxodO67t3nCreoz1ZpmgO0zmKvru2iwoZaIZLsFrliv3YTTkhhsUXisT
Z6lHdLZrsyCT + mhsGAzz1pFu5Cz1oDhIW2Oorkomt3bnEW1YBPSCHNWbAoGBANZQ
pW60gDFz97foG1TBdZBz19egvdwnkI5Bhq + nTI8qFso6Z8A1YlRUF8uD66LTHp7v
hanWxkULy3UdvbO6AhvbDqrDxCpyqx91mfrkJjgHFLYSWXnW / gqkOc / gvfXXUQt3
ni5IdO4QPuK4CMHdOXsHLhPA9SIEFUebyQG + xmATAoGAQds0t + ppyL4ALbiP + cee
27hA6JUyqqFtIQOZmt5k1VP5RIY8D1Uu3bjmIlMwg23ucKYJanjneDbi53aAb2JF
1erwshGWC1v8JWNck0Bb0gFgm0MimWxBUBFLMNmG / 5oMGB9HNU + 44AVoUO3Z4Tmi
2TJ3s21zjAdD8ZiEUOiVXX0CgYEAxheE0e7FDvDB55sCqDSpFfv9ZbGNzBBF7Tdj
5rgca7fbmNCjVWYCnS + dTt + Azd + WThHW2kVKvkdIp9f1oEot6NFxnSWWDCYxRcLN
sLlxGhhxbFlJmvS9m9hwF1UEQFfk8VR / QQh4DBO4DJdOgOKaXr0kOd4AtpBPmwDD
qnlLo0ECgYEApSikNmX5gzjjWiYJrI9bScuWXKmFMbsp9VjKQEoKdu6O8TrrIY + 5
EAyPxcoDrGfP3vJBF9v5QUV7CI5 + / Vr2W1ALyrn + GySNP74HIxIJ3ma / MW5UYLjw
FsTuJK0DHUEWNQcz + BI1TMWjTte00XBM / 3egd +++ 5n9uUHERp / 8pV70 =
----- END RSA PRIVATE KEY -----
Here is the Regex that I developed :
(-----BEGIN RSA PRIVATE KEY-----\n)\K.*+(?>\n.*)*?(?=\n(-----END RSA PRIVATE KEY-----))
I check for :
- the presence of '-----BEGIN RSA PRIVATE KEY-----' at the beginning with a line break.
- several lines with any type of character and a line break.
- the presence of value '-----END RSA PRIVATE KEY-----'
I find this script but it doesn't work :
Catalog client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var regex = g_form.getValue('scm_rsa_key_private_part');
if(!regex.match('(-----BEGIN RSA PRIVATE KEY-----\n)\K.*+(?>\n.*)*?(?=\n(-----END RSA PRIVATE KEY-----))')){
alert('Please enter a valid RAS key');
g_form.setValue('scm_rsa_key_private_part','');
}
}
Have you any idea ?
Thanks you
Solved! Go to Solution.
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 09:41 AM
Hello All,
Here is the solution that works for me.
Catalog client script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var getval = g_form.getValue('YOURFIELD'); //Replace YOURFIELD by the name of your field.
var regex = '-----BEGIN RSA PRIVATE KEY-----([^-!]+)-----END RSA PRIVATE KEY-----'; //Regex for RSA key (Private part)
if(!getval.match(regex)){
g_form.addErrorMessage('Please enter a valid RSA Key (Private Part).');
g_form.setValue('YOURFIELD','-----BEGIN RSA PRIVATE KEY-----\n!YourRSAkey!\n-----END RSA PRIVATE KEY-----'); //Replace YOURFIELD by the name of your field.
return false;
}
}
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 08:22 AM
Your regular expression doesnt match the string .
You can verify it in regex101.com website.
First you need to make correct regex and then proceed forward .
Go to this site to brush up your regex skills
Mark my ANSWER as CORRECT and HELPFUL if it helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 08:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 09:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 10:01 AM
Hi,
Here is link which will help you.
https://stackoverflow.com/questions/587345/regular-expression-matching-a-multiline-block-of-text
If it helps,Please mark ✅ Correct and 👍 Helpful.
Warm Regards,
Milind