NotePlan / NotePlan/plugins

field-level validation in settings

Open
#212 1 comment 0 reactions 1 assignee View on GitHub

@EduardMe is already working on this.

Since Jan 25, 2022.

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

Description

in plugin.json > settings, define an (optional) validation function that will get called for each field in the settings, with a signature like:

onConfigFieldValidate(fieldName: string, fieldValue: string | number | ... ): string

The validation function will return an empty string '' if validation passes, or an error message to be displayed (e.g. in red under the field) if it does not pass.

The only tricky bit is when to call the validation function. Feels like the ideal is to do all of:
a) on settings load (when the settings window is brought up)
b) on blur (when someone has entered and left a field)
c) on "Save and close" click (errors would cancel the close)

More discussion here:
https://discord.com/channels/@me/928678751808671865/935560749823164486

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.