NotePlan / NotePlan/plugins

Add Validation to Plugin Setting Schema

Aperta
#198 2 commenti 0 reazioni 2 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

API enhancement
Lingua principale
JavaScript
Stelle
204
Fork
82
Merge medio
22h 27m
PR unite (30g)
3

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.