feature: assertions
See original GitHub issueRequest for comments
This feature request is not yet actionable. We need to collect some feedback first.
Is your feature request related to a problem? Please describe. We need a generic rules to be used in cases which our other built-in rules do not cover.
Describe the solution you’d like I’d like to have a set of built-in rules which can be configured to enforce different generic usecases:
enum
to enforce a value to be among set of predefined valuespattern
- to enforce a value to match a regexcasing
- to enforce specific casing style (camelCase, kebab-case, snake_case, PascalCase)mutuallyExclusive
- to mark some properties as mutually exclusive (a
orb
but nota
andb
together)defined
/undefined
/nonEmpty
length
- to enforce length of specific array or stringsortOrder
- to enforce sort order in array of strings or array of objects (collection)
Example usage:
lint:
rules:
enforcements: # I would like a better suggestion here
- on: SecuritySchema.type
description: Only API key authorization is allowed
severity: error
enum:
- apiKey
- on: 'MediaTypeMap.$keys'
enum:
- apiKey
- on: MediaTypeMap.$keys
description: Only application/json can be used
enum:
- 'application/json'
nonEmpty:
description: Schema title and description should be non-empty
locations:
- on: Schema.description
- on: Schema.title
Additional context none
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Assertion (software development) - Wikipedia
In computer programming, specifically when using the imperative programming paradigm, an assertion is a predicate (a Boolean-valued function over the state ...
Read more >Assertions - JavaScript - MDN Web Docs
Assertions include boundaries, which indicate the beginnings and endings of lines and words, and other patterns indicating in some way that a match...
Read more >Programming With Assertions - Oracle Help Center
An assertion is a statement in the Java TM programming language that ... We enhanced Throwable with the getStackTrace method to provide this...
Read more >Getting started with Assertions | Functional Testing - SoapUI
Lets look at how the Assertion functionality of the Sampler TestSteps are used to validate the incoming response or request received by the...
Read more >Assert feature — oneAPI DPC++ Compiler documentation
This document describes the design of supporting assertions within SYCL device ... Abort host application when assert function is called and print a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I like per-key approach better (allowing “on” to be an array makes it even better)
Depending on the selected format the UI will be different. In the original case we’re grouping by node type and I see flow in the UI like the following: (you may think of chain items as form controls):
In the alternative case we’re grouping by rule and then pull in node types, so in the UI selecting rule should go before selecting node type:
I prefer the enforcements approach. For me it’s more naturally when you take a node and then describe a rule for it, not vice versa. Other benefits from it what I see so far are:
Easier to generate code for the rule. For example this configuration
will result in 4 different rules:
With more atomic rules we will get more granularity for severity and error messages