| import matchTheSchemaType from './match-schema-type' | import matchTheSchemaType from './match-schema-type' | ||||
| export const getMatchedSchemaType = (obj: AnyObj, schemaTypeDefinitions?: SchemaTypeDefinition[]): string => { | export const getMatchedSchemaType = (obj: AnyObj, schemaTypeDefinitions?: SchemaTypeDefinition[]): string => { | ||||
| if(!schemaTypeDefinitions) return '' | |||||
| if(!schemaTypeDefinitions || obj === undefined || obj === null) return '' | |||||
| const matched = schemaTypeDefinitions.find(def => matchTheSchemaType(obj, def.schema)) | const matched = schemaTypeDefinitions.find(def => matchTheSchemaType(obj, def.schema)) | ||||
| return matched ? matched.name : '' | return matched ? matched.name : '' | ||||
| } | } |