fix: ajv mapping parity to joi - #214
Merged
Merged
Conversation
gibaros
requested review from
bushjames,
elnyry-sam-k,
geka-evk,
kalinkrustev,
kleyow,
oderayi,
shashi165 and
vijayg10
as code owners
July 30, 2026 14:32
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Adds four Ajv keyword cases to
createFSPIOPErrorFromOpenapiErrorso they map to FSPIOP 3101 "Malformed syntax", matching whatcreateFSPIOPErrorFromJoiErrorhas done for years:enum,constany.only/any.allowOnly(added for mojaloop/project#2013)formatdate.format,string.email/uri/guidpatternstring.regexAlso includes a dev-dependency refresh (ncu 23, sinon 22.1.0, brace-expansion 5.0.8, js-yaml 4.3.0).
Why
When services migrated from hapi-openapi/joi to openapi-backend/Ajv, syntactically-invalid values (bad enum values, malformed date-times, regex violations) silently changed from 3101 "Malformed syntax" to the default 3100 "Generic validation error" — the Ajv switch never received the curation the joi switch accumulated (see #2013, which added
any.onlyfor exactly this reason). This surfaced as a breaking change in the central-ledger/central-settlement OpenAPI 3.0.3 migration (mojaloop/project#4479): Golden Path test "Check Settlements Error #956" asserts 3101 for an invalid enum query value. With this fix, that migration ships with no API-visible behavior change.Deliberately NOT mapped
minLength/maxLengthstay at 3100: existing openapi-backend services already expose 3100 there and Golden Path asserts it (quotes_negative). A guard test in this PR pins that behavior. Restoring full joi parity for these (incl. joi'sany.empty→ 3102 for empty strings) is a follow-up proposal with its own GP test updates.minimum,maximum,minItems, …) stay at 3100 — the joi switch never mapped them either; parity means restraint.Validation
Release
fix:→ patch (13.1.8), consistent with the #2013 precedent (released as 12.0.1). Consumers adopt via explicit dependency bumps; nothing changes for services pinned to ≤13.1.7.Part of mojaloop/project#4479.
🤖 Generated with Claude Code