added formData to validation function
Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
@@ -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>;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user