Validate Setting

Is there a way to validate a Setting value before saving it, and to laert the user the value is invalid? e.g. Set the contol element’s border to a different color and display a message describing why the value is invalid.

Can you give a specific example? Or explain what trouble you’re seeing? Do you not get useful errors or warnings?

(I haven’t used the API, so maybe the question would be clear to someone more experienced than me. But an example might help to get answers to this.)

For instance, in my plugin (GitHub - bicarlsen/obsidian_image_caption: Add captions to images in Obsidian.) I would like to validate the Delimeter setting to make sure a use has entered either a zero, one, or two delimeters separated by a comma. If the user has eneterd an invalid delimeter string I would like to alert them that it is invalid and provide an explanation as to why.

1 Like