From 67ee34dcaede5012d4e1d75883878919e5746d01 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 7 Sep 2021 15:07:40 +0200 Subject: [PATCH] docs: added some more examples Signed-off-by: blam --- .../writing-custom-field-extensions.md | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/features/software-templates/writing-custom-field-extensions.md b/docs/features/software-templates/writing-custom-field-extensions.md index e32aa4e78d..cf0a1e5d8f 100644 --- a/docs/features/software-templates/writing-custom-field-extensions.md +++ b/docs/features/software-templates/writing-custom-field-extensions.md @@ -26,9 +26,31 @@ You can create your own Field Extension by using the ```tsx //packages/app/scaffolder/MyCustomExtension/MyCustomExtension.tsx -export const MyCustomExtension = () => {}; +import { FieldProps } from '@rjsf/core'; +export const MyCustomExtension = ({ onChange, required }: FieldProps) => { + return ( + 0 && !formData} + > + ) +}; ``` ```tsx // packages/app/scaffolder/MyCustomExtension/validation.ts +import { FieldValidation } from '@rjsf/core'; +import { KubernetesValidatorFunctions } from '@backstage/catalog-model'; + +export const myCustomValidation = ( + value: string, + validation: FieldValidation, +) => { + if (!KubernetesValidatorFunctions.isValidObjectName(value)) { + validation.addError( + 'must start and end with an alphanumeric character, and contain only alphanumeric characters, hyphens, underscores, and periods. Maximum length is 63 characters.', + ); + } +}; ```