Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function validateValue(schema, value, properties, customValidationFn) {
const validationSchema = adaptAdditionalRules(schema);
const staticResult = validate(validationSchema, value);
if (staticResult.valid && schema.customValidation && customValidationFn) {
return customValidationFn(schema, value, properties);
}
return staticResult.valid ? null : staticResult.error.message;
}
export default function Widget({ id, schema }) {
const { properties } = useContext(formContext);
const WidgetComponent = widgetDictionary[schema.widget || schema.type];
const value = getValue(properties, schema);
const widgetId = sfPath.name(schema.key, '_', id);
return ;
}
Widget.propTypes = {
const values = rhf.getValues({ nest: true });
if (!shouldRender(condition, values, key)) {
return null;
}
const widgetName = widget || type;
const WidgetImpl = getWidget(displayMode || schema.displayMode, widgetName, widgets);
if (!WidgetImpl) {
return <p>Widget not found {widgetName}</p>;
}
const instance = (
);
if (tooltip) {
return (
<div>{instance}</div>
);
tooltip,
tooltipPlacement,
} = props.schema;
const widgetId = widget || type;
if (widgetId === 'hidden' || !shouldRender(condition, props.properties, key)) {
return null;
}
const WidgetImpl = getWidget(props.displayMode || displayMode, widgetId, props.widgets);
if (!WidgetImpl) {
return <p>Widget not found {widgetId}</p>;
}
const id = sfPath.name(key, '_', props.id);
const error = getError(props.errors, props.schema);
const errorMessage = validationMessage || error;
const all = {
...props,
id,
key: id,
options,
errorMessage,
isValid: !error,
value: getValue(props.properties, props.schema),
valueIsUpdating: isUpdating(props.updating, props.schema.key),
};
if (tooltip) {
return (
export default (jsonSchema, uiSchema) => {
const props = { jsonSchema, uiSchema };
if (!jsonSchema) {
return props;
}
props.mergedSchema = merge(props.jsonSchema, props.uiSchema);
return props;
};