diff --git a/src/primitive-field/primitive-field.component.ts b/src/primitive-field/primitive-field.component.ts index ac45aba..c7dff91 100644 --- a/src/primitive-field/primitive-field.component.ts +++ b/src/primitive-field/primitive-field.component.ts @@ -110,10 +110,7 @@ export class PrimitiveFieldComponent extends AbstractFieldComponent implements O if (this.schema.onValueChange) { // setTimeout to workaround the case when the value is changed back to previous value inside onValuChange callback - setTimeout( () => { - this.schema.onValueChange(this.path, this.value, this.jsonStoreService, this.keysStoreService); - this.validate(); - } + setTimeout( () => this.schema.onValueChange(this.path, this.value, this.jsonStoreService, this.keysStoreService) ); } } @@ -134,7 +131,7 @@ export class PrimitiveFieldComponent extends AbstractFieldComponent implements O } onValueChange(value: string) { - this.value = value; + this.value = this.schema.stripWhitespace ? value.trim() : value; } onSearchableDropdownSelect(value: string) { diff --git a/src/shared/interfaces/schema-option.ts b/src/shared/interfaces/schema-option.ts index f6150df..5aea6c4 100644 --- a/src/shared/interfaces/schema-option.ts +++ b/src/shared/interfaces/schema-option.ts @@ -134,4 +134,9 @@ export interface SchemaOption { * Names of templates to be put as extra custom items to title dropdown. */ titleDropdownItemTemplateNames?: Array; + + /** + * Configuration for striping whitespaces from field value + */ + stripWhitespace?: boolean; }