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.

RFC: config validation

See original GitHub issue

Context

While working on #2398 I noticed that we are not validating if config provided has correct structure at all, in this pr i added basic validation for resolved configuration as doing unsafe type casting is really bad idea

Proposed implementation in not ideal, and requires more refining.

Proposal

Create new package responsible for validation of configuration and rules @commitlint/config-validator and use ajv to validate configurations loaded by @commitlint/load and @commitlint/resolve-extends

Validation should be done in 2 steps: config and rules

Config validation #2412

this should be first step of validation of config structure and type check properties, but it should not validate structure of specific rules as by default we should accept any configuration that matches

'string': [RuleConfigSeverity /* 0, 1, 2 */, RuleConfigCondition /* when */, unknown /* options */]

Rules validation

after resolving and merging all extended configs we should proceed to validate options for rules: this is going to require change in structure of rule definition, we should add support for object and deprecate raw functions

in case if we don’t have schema for rule, we should skip validation of options

Rule as object

schema property is optional, but recommended,

  • if provided we should validate options against it
  • if not provided we should threat options as any/unknown
{
  schema: { ... },
  handler (parsed, when = 'always', options) { } // I'm not sure about this name, but this can be refined/changed
}

Rule as function - backward compatibility

It should be threated as there is no schema provided and we should accept any options

function rule (parsed, when = 'always', options) {}

Why we should change default structure of rules

with moving away of simple function structure it gives us possibility:

  • to extend rules to provide more functionality in feature like requested fixing behavior. (#584)
  • provide meaningful configuration errors (#2384)
  • add ability to validate configurations provided by this project: config-angular-type-enum, config-angular, config-conventional, config-lerna-scopes, config-patternplate (#889)
  • ~ability to expose json-schema for IDE to provide syntax autocompletion~
  • This feature was requested before: #263, #835

this is my general idea for this, its not written in best way, but I’d like to hear your opinion on this

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
armano2commented, Jan 20, 2021
1reaction
armano2commented, Jan 15, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Validating the RFC Connection - SAP Community
I have followed the instructions for Validating a connection between SAP R/3 and SAP XI with RFC... When running stfc_connection in se37, i...
Read more >
RFC 7039 - Source Address Validation Improvement (SAVI ...
RFC 7039 SAVI Framework October 2013 2. Model To enable network operators to deploy fine-grained IP source address validation without a dependency on ......
Read more >
RFC 6241: Network Configuration Protocol (NETCONF)
1. Description Validation consists of checking a complete configuration for syntactical and semantic errors before applying the configuration to the device. · 2....
Read more >
rfc-http-validate - PyPI
rfc -http-validate · Optionally, starts with a valid HTTP/1.1 request or status line · Has one or more HTTP/1.1 header field lines, possibly...
Read more >
How to Configure & Test RFC Connection in SAP – SM59
Authorization Test -> It is used to validate the User ID and Password (provided under 'logon and security' tab for the target system)...
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