NotePlan / NotePlan/plugins

Add Validation to Plugin Setting Schema

Abierto
#198 2 comentarios 0 reacciones 2 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

API enhancement
Lenguaje dominante
JavaScript
Estrellas
204
Forks
82
Merge medio
22 h 27 min
PR fusionados (30 d)
3

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.