anvil/striker-ui/lib/buildYupDynamicObject.ts

15 lines
303 B
TypeScript
Raw Normal View History

const buildYupDynamicObject = <S>(
obj: Record<string, S> | undefined,
schema: S,
): Record<string, S> | undefined =>
obj &&
Object.keys(obj).reduce<Record<string, S>>(
(previous, key) => ({
...previous,
[key]: schema,
}),
{},
);
export default buildYupDynamicObject;