added formData to validation function

Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
Alex Rybchenko
2022-11-18 14:16:58 +01:00
parent 94a2e86ce1
commit 42addd8c8d
3 changed files with 8 additions and 6 deletions
+5 -4
View File
@@ -110,9 +110,9 @@ export type EntityPickerUiOptions =
export const EntityTagsPickerFieldExtension: FieldExtensionComponent<
string[],
{
showCounts?: boolean | undefined;
kinds?: string[] | undefined;
helperText?: string | undefined;
kinds?: string[] | undefined;
showCounts?: boolean | undefined;
}
>;
@@ -120,9 +120,9 @@ export const EntityTagsPickerFieldExtension: FieldExtensionComponent<
export const EntityTagsPickerFieldSchema: FieldSchema<
string[],
{
showCounts?: boolean | undefined;
kinds?: string[] | undefined;
helperText?: string | undefined;
kinds?: string[] | undefined;
showCounts?: boolean | undefined;
}
>;
@@ -224,6 +224,7 @@ export type NextCustomFieldValidator<TFieldReturnValue> = (
field: FieldValidation_2,
context: {
apiHolder: ApiHolder;
formData: JsonObject;
},
) => void | Promise<void>;
+2 -1
View File
@@ -23,6 +23,7 @@ import {
} from '@rjsf/utils';
import { PropsWithChildren } from 'react';
import { JSONSchema7 } from 'json-schema';
import { JsonObject } from '@backstage/types';
/**
* Field validation type for Custom Field Extensions.
@@ -100,7 +101,7 @@ export interface NextFieldExtensionComponentProps<
export type NextCustomFieldValidator<TFieldReturnValue> = (
data: TFieldReturnValue,
field: FieldValidationV5,
context: { apiHolder: ApiHolder },
context: { apiHolder: ApiHolder; formData: JsonObject },
) => void | Promise<void>;
/**
@@ -42,7 +42,7 @@ export const createAsyncValidators = (
if (validator) {
const fieldValidation = createFieldValidation();
try {
await validator(value, fieldValidation, context);
await validator(value, fieldValidation, { ...context, formData });
} catch (ex) {
fieldValidation.addError(ex.message);
}