Skip to content

Commit

Permalink
Improve 'toDataPath' documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jlarrubiaq committed Jan 2, 2023
1 parent 9f045c4 commit ef9305a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/util/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ export const toDataPathSegments = (schemaPath: string): string[] => {
};

/**
* Remove all schema-specific keywords (e.g. 'properties') from a given path.
* Convert a schema path (i.e. JSON pointer) to a data path.
*
* Data paths can be used in field change event handlers like handleChange.
*
* @example
* toDataPath('#/properties/foo/properties/bar') === '#/foo/bar')
* toDataPath('#/properties/foo/properties/bar') === 'foo.bar')
*
* @param {string} schemaPath the schema path to be converted
* @returns {string} the path without schema-specific keywords
* @returns {string} the data path
*/
export const toDataPath = (schemaPath: string): string => {
return toDataPathSegments(schemaPath).join('.');
Expand Down

0 comments on commit ef9305a

Please sign in to comment.