@@ -37,7 +37,7 @@ import {
3737 useWarningStore ,
3838 useYamlStore ,
3939} from "../lib/store" ;
40- import { getYaml } from "../lib/utils" ;
40+ import { getYaml , collectRemovedKeys } from "../lib/utils" ;
4141import linter from "../linter" ;
4242import publicCodeAdapter from "../publiccode-adapter" ;
4343import { toSemVerObject } from "../semver" ;
@@ -61,34 +61,6 @@ import PubliccodeYmlLanguages from "./PubliccodeYmlLanguages";
6161import { yamlLoadEventBus } from "./UploadPanel" ;
6262// import EditorMDInput from "./EditorMDInput";
6363
64- function collectRemovedKeys ( original : unknown , sanitized : unknown , prefix = "" ) : Array < string > {
65- const removed : Array < string > = [ ] ;
66-
67- if ( original && typeof original === "object" && ! Array . isArray ( original ) ) {
68- const originalObj = original as Record < string , unknown > ;
69- const sanitizedObj = ( sanitized && typeof sanitized === "object" && ! Array . isArray ( sanitized ) )
70- ? ( sanitized as Record < string , unknown > )
71- : { } ;
72-
73- for ( const key of Object . keys ( originalObj ) ) {
74- const nextPrefix = prefix ? `${ prefix } .${ key } ` : key ;
75- if ( ! ( key in sanitizedObj ) || ( sanitizedObj as Record < string , unknown > ) [ key ] === undefined ) {
76- removed . push ( nextPrefix ) ;
77- } else {
78- removed . push (
79- ...collectRemovedKeys (
80- ( originalObj as Record < string , unknown > ) [ key ] ,
81- ( sanitizedObj as Record < string , unknown > ) [ key ] ,
82- nextPrefix
83- )
84- ) ;
85- }
86- }
87- }
88-
89- return removed ;
90- }
91-
9264const validatorFn = async ( values : PublicCode ) => {
9365 try {
9466 const yaml = getYaml ( values ) ?? "" ;
0 commit comments