import { registerExamples } from '../register' ; import { UISchemaElement , updateErrors , JsonFormsCore , AnyAction , Dispatch } from '@jsonforms/core' ; let touchedProperties = { name : false , description : false } ; export const onChange = ( dispatch ) => ( _ ) => ( { data , errors } ) => { Object . keys ( data ) . forEach ( key => ( touchedProperties [ key ] = true ) ) ; const newErrors = errors . filter ( error => { return touchedProperties [ ( error as any ) . dataPath ?? error . instancePath ] ; } ) ; if ( newErrors . length < errors . length ) { return dispatch ( updateErrors ( newErrors ) ) ; } } ; export const schema = { type : 'object' , properties : { name : { type : 'string' , minLength : 1 } , description : { type : 'string' , minLength : 1 } } , required : [ 'name' , 'description' ] } ; export const uischema = undefined ; export const data = { } ; registerExamples ( [ { name : 'onChange' , label : 'On Change' , data , schema , uischema } ] ) ;