Skip to content

Commit cdf45c4

Browse files
committed
chore: Add basic docs to pickXKey and buildCompleteYupSchema
1 parent 86490ea commit cdf45c4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/internals/helpers.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import isEmpty from 'lodash/isEmpty';
1010
import isFunction from 'lodash/isFunction';
1111

1212
/**
13-
* Returns the object from the JSON-schema node using the key.
14-
*
13+
* Shorthand to lookup for keys with `x-jsf-*` preffix.
1514
* @param {Object} node - JSON-schema node
16-
* @param {String} key - JSON-schema key name
15+
* @param {"presentation"|"errorMessage"} key - JSON-schema key name
16+
* @example
17+
* pickKey(properties, 'presentation')
18+
* is the same as properties["x-jsf-presentation"]
1719
* @returns {Object}
1820
*/
1921
export function pickXKey(node, key) {

src/yupSchema.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { convertDiskSizeFromTo } from './utils';
88

99
/**
1010
* @typedef {import('./createHeadlessForm').FieldParameters} FieldParameters
11+
* @typedef {import('../createHeadlessForm').JsfConfig} JsfConfig
1112
*/
1213

1314
export const DEFAULT_DATE_FORMAT = 'yyyy-MM-dd';
@@ -297,6 +298,14 @@ function getSchema(fields = [], config) {
297298
return newSchema;
298299
}
299300

301+
/**
302+
* Returns the Yup schema structure of given fields.
303+
* These fields must be the same from
304+
* const { fields } = createHeadlessForm()
305+
* @param {Fields[]} fields - List of fields
306+
* @param {JsfConfig} config - Config
307+
* @returns
308+
*/
300309
export function buildCompleteYupSchema(fields, config) {
301310
return object().shape(getSchema(fields, config), getNoSortEdges(fields));
302311
}

0 commit comments

Comments
 (0)