NotePlan / NotePlan/plugins

Add Validation to Plugin Setting Schema

Open
#198 2 comments 0 reactions 2 assignees View on GitHub

Nobody has claimed this yet.

API enhancement
Dominant language
JavaScript
Stars
204
Forks
82
Avg merge
22h 27m
Merged PRs (30d)
3

Description

We have replaced the config defaults part of the code but have not replaced the field validation part. Validation should be added to the spec. For example, my /atb plugin has the following config field validations:

    todoChar: /^(?!(?:.*\*){2})[\*|\-|#{1,}]+$/,
    timeBlockHeading: /^[^#+].*/,
    workDayStart: /^\d{2}:\d{2}$/,
    workDayEnd: /^\d{2}:\d{2}$/,

Maybe this is not MVP, but it should be in the dot-one release of settings. Validation settings should be included in the plugin settings so that Eduard can validate the field that the user has entered. I am going to add a regex field called "validation" (a string with escaped RegEx) to my plugin.settings, e.g.:

  "plugin.settings": [
    {
        "key": "todoChar",
        "type": "string",
        "validation": "^(?!(?:.*\\*){2})[\\*|\\-|#{1,}]+$",
	"choices": ["*","-","#","##","###","####"],
        "title": "Time Block Leading Character",
        "description": "For NotePlan to recognize a line as a Time Block, the leading character must be one of: a '*', a '-' or one or more '#'s. You can choose between the 3, but if you are going to create real calendar events from your Time Blocks, you must use the *",
        "default": "*",
        "required": true
    }
  ]

Maybe this is not the ideal example, because there are 'choices', and a user cannot enter other values. But I have many of these, some of which are free-text-entry.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.