mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
bugfix/adding checkOptionalShortString and using in CreateBank v5.1.0
This commit is contained in:
parent
8143f6449a
commit
d275ec71a2
@ -911,6 +911,18 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
|
||||
}
|
||||
}
|
||||
|
||||
/** only A-Z, a-z, 0-9, -, _, ., and max length <= 16, allows empty string */
|
||||
def checkOptionalShortString(value:String): String ={
|
||||
val valueLength = value.length
|
||||
val regex = """^([A-Za-z0-9\-._]*)$""".r
|
||||
value match {
|
||||
case regex(e) if(valueLength <= 16) => SILENCE_IS_GOLDEN
|
||||
case regex(e) if(valueLength > 16) => ErrorMessages.InvalidValueLength
|
||||
case _ => ErrorMessages.InvalidValueCharacters
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** only A-Z, a-z, 0-9, -, _, ., and max length <= 36
|
||||
* OBP APIUtil.generateUUID() length is 36 here.*/
|
||||
|
||||
@ -182,7 +182,7 @@ trait APIMethods500 {
|
||||
}
|
||||
|
||||
//if postJson.id is empty, just return SILENCE_IS_GOLDEN, and will pass the guard.
|
||||
checkShortStringValue = APIUtil.checkShortString(postJson.id.getOrElse(SILENCE_IS_GOLDEN))
|
||||
checkShortStringValue = APIUtil.checkOptionalShortString(postJson.id.getOrElse(SILENCE_IS_GOLDEN))
|
||||
_ <- Helper.booleanToFuture(failMsg = s"$checkShortStringValue.", cc = cc.callContext) {
|
||||
checkShortStringValue == SILENCE_IS_GOLDEN
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user