* feat: WIP extended validation function arguments * chore: optimizes validation extended args * chore: more consistently passes validation args * chore: removes field from form state * chore: passing tests * fix: default point validation allows not required and some edge cases * chore: ensures default validate functions receive field config * chore: demo validation with sibling data * chore: optimize getDatabByPath and getSiblingData * chore: adds tests to validate extra arg options * docs: add validation arguments * chore: export default field validation * chore: top level getSiblingData * fix: #495, avoids appending version to id queries * chore: revises when field validation is run * chore: restore original admin field validation Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
21 lines
458 B
TypeScript
21 lines
458 B
TypeScript
import { unflatten as flatleyUnflatten } from 'flatley';
|
|
import { Data, Fields } from './types';
|
|
|
|
const reduceFieldsToValues = (fields: Fields, unflatten?: boolean): Data => {
|
|
const data = {};
|
|
|
|
Object.keys(fields).forEach((key) => {
|
|
if (!fields[key].disableFormData) {
|
|
data[key] = fields[key].value;
|
|
}
|
|
});
|
|
|
|
if (unflatten) {
|
|
return flatleyUnflatten(data, { safe: true });
|
|
}
|
|
|
|
return data;
|
|
};
|
|
|
|
export default reduceFieldsToValues;
|