Commit ed884e74 authored by Dave Pisek's avatar Dave Pisek

Feedback: Add jsdoc to directive factory

Add jsdoc to explain the directive's parameters and how they
affect the shown validation messages.
parent a6f17159
......@@ -58,6 +58,21 @@ const createValidator = (context, feedbackMap) => ({ el, reportValidity = false
form.state = isEveryFieldValid(form);
};
/**
* Takes an object that allows to add or change custom feedback messages:
*
* validate({
* tooLong: {
* check: el => el.validity.tooLong === true,
* message: 'The value you have entered is too long'
* }
* })
*
* Note: The passed in object will be merged with the built-in feedback.
*
* @param {Object<string, {isValid: function, message: string}>} customFeedbackMap
* @returns {{ inserted: function, update: function }} validateDirective
*/
export default function(customFeedbackMap = {}) {
const feedbackMap = merge(defaultFeedbackMap, customFeedbackMap);
const elDataMap = new WeakMap();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment