NotePlan / NotePlan/plugins

Add Validation to Plugin Setting Schema

Offen
#198 2 Kommentare 0 Reaktionen 2 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

API enhancement
Vorherrschende Sprache
JavaScript
Sterne
204
Forks
82
Ø Merge
22 Std. 27 Min.
Gemergte PRs (30 T.)
3

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.