question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to check somehow the group of params? E.g.: I have three query params on input: one, two, three, and I want to check if one of them is present. Im using schema validation.

It looks like a problem because schemas are referencing always to the specific fields :~

    'limit': {
        optional: true,
        isInt: {
            errorMessage: 'Invalid argument type.'
        }
    },
    'offset': {
        optional: true,
        isInt: {
            errorMessage: 'Invalid argument type.'
        }
    }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
maZahacacommented, Dec 22, 2016

Is there an option to check several fields of request, the whole request? For example, my api receive a request from transfer money tool, which has parameters:

{
   "fromAccount":"100001",
   "toAccount":"100001",
   "amount":2344.23,
}

So we validated each parameter in separate way, but we also need to check that fromAccount !== toAccount somehow.

2reactions
gustavohenkecommented, Dec 17, 2016

@agauniyal you can already do this. These 3 fields are always required, and make the 4th one optional. If one of these 3 fields are not sent, then the request should fail.

Read more comments on GitHub >

github_iconTop Results From Across the Web

oneOf, anyOf, allOf, not - Swagger
Use the anyOf keyword to validate the data against any amount of the given subschemas. That is, the data may be valid against...
Read more >
oneOf / anyOf / allOf - react-jsonschema-form documentation
react-jsonschema-form supports custom widgets for oneOf, anyOf, and allOf. A schema with oneOf is valid if exactly one of the subschemas is valid....
Read more >
What is the difference between "anyof" and "oneof" in z schema?
oneOf means the item needs to be tested against each schema even after it matches one, and if it matches another one, the...
Read more >
AllOf, AnyOf, OneOf - Liquid Technologies
The AllOf, AnyOf, OneOf nodes are all optional, and a schema can contain any combination of them. Example - Multiple Versions of a...
Read more >
Understanding JSON Schema 2020-12 documentation
anyOf : (OR) Must be valid against any of the subschemas; oneOf: (XOR) Must be valid against exactly one of the subschemas. All...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found