@@ -22,9 +22,36 @@ export class GnMetadataQualityComponent extends BaseComponent {
2222 @Input ( ) smaller = false
2323 @Input ( ) metadataQualityDisplay = true
2424 @Input ( ) popoverDisplay = true
25- @Input ( ) propsToValidate ?: ValidatorMapperKeys [ ] | string // Can be JSON string array
2625 @Input ( ) forceComputeScore = false
2726
27+ private _propsToValidate ?: ValidatorMapperKeys [ ] | string
28+ public parsedPropsToValidate ?: ValidatorMapperKeys [ ]
29+
30+ @Input ( )
31+ set propsToValidate ( value : ValidatorMapperKeys [ ] | string | undefined ) {
32+ this . _propsToValidate = value
33+ if ( ! value ) {
34+ this . parsedPropsToValidate = undefined
35+ return
36+ }
37+ if ( typeof value === 'string' ) {
38+ try {
39+ const parsed = JSON . parse ( value )
40+ this . parsedPropsToValidate = Array . isArray ( parsed ) ? parsed : undefined
41+ } catch ( e ) {
42+ console . warn ( 'Failed to parse propsToValidate JSON:' , e )
43+ this . parsedPropsToValidate = undefined
44+ }
45+ } else if ( Array . isArray ( value ) ) {
46+ this . parsedPropsToValidate = value
47+ } else {
48+ this . parsedPropsToValidate = undefined
49+ }
50+ }
51+ get propsToValidate ( ) {
52+ return this . _propsToValidate
53+ }
54+
2855 get parsedMetadata ( ) : CatalogRecord | null {
2956 if ( ! this . metadata ) return null
3057 if ( typeof this . metadata === 'string' ) {
@@ -38,19 +65,6 @@ export class GnMetadataQualityComponent extends BaseComponent {
3865 return this . metadata
3966 }
4067
41- get parsedPropsToValidate ( ) : ValidatorMapperKeys [ ] | undefined {
42- if ( ! this . propsToValidate ) return undefined
43- if ( typeof this . propsToValidate === 'string' ) {
44- try {
45- return JSON . parse ( this . propsToValidate )
46- } catch ( e ) {
47- console . warn ( 'Failed to parse propsToValidate JSON:' , e )
48- return undefined
49- }
50- }
51- return this . propsToValidate
52- }
53-
5468 get parsedForceComputeScore ( ) : boolean {
5569 if ( typeof this . forceComputeScore === 'boolean' ) return this . forceComputeScore
5670 return this . forceComputeScore === 'true' || this . forceComputeScore === true
0 commit comments