@@ -141,14 +141,38 @@ DocumentFrame.prototype.filterFrame = function(loadRenderer){
141141 frame . compare = rule . compare ( ) ;
142142 }
143143 if ( rule . errors ( ) ) {
144- frame . errors = rule . errors ( ) ;
145- }
144+ frame . errors = frame . errors ? frame . errors . concat ( rule . errors ( ) ) : rule . errors ( ) ;
145+ }
146+ else if ( rule . errors ( ) === false ) delete frame . errors
146147 }
147148 this . applyRules ( false , false , myfilt ) ;
148149}
149150
151+ DocumentFrame . prototype . setErrors = function ( errors ) {
152+ this . clearErrors ( )
153+ let frameconf = TerminusClient . View . document ( )
154+ for ( var i = 0 ; i < errors . length ; i ++ ) {
155+ addRuleForVio ( frameconf , errors [ i ] )
156+ }
157+ this . applyRules ( false , frameconf ) ;
158+ }
159+
160+ DocumentFrame . prototype . clearErrors = function ( ) {
161+ frameconf . all ( ) . errors ( false )
162+ this . applyRules ( false , frameconf )
163+ }
164+
165+ function addRuleForVio ( docview , error ) {
166+ let prop = ( error [ 'api:property' ] ? error [ 'api:property' ] [ "@value" ] : false )
167+ let subj = ( error [ 'api:subject' ] ? error [ 'api:subject' ] [ "@value" ] : false )
168+ let val = ( error [ 'api:value' ] ? error [ 'api:value' ] [ "@value" ] : false )
169+ let type = ( error [ 'api:type' ] ? error [ 'api:type' ] [ "@value" ] : false )
170+ if ( type && val ) { //api:BadCast
171+ frameconf . data ( ) . value ( val ) . range ( type ) . errors ( [ error ] )
172+ }
173+ }
150174
151- /*
175+ /*"
152176 * adds render and compare functions to object frames
153177 */
154178DocumentFrame . prototype . applyRules = function ( doc , config , mymatch ) {
0 commit comments