@@ -153,21 +153,38 @@ DocumentFrame.prototype.setErrors = function(errors, frameconf){
153153 for ( var i = 0 ; i < errors . length ; i ++ ) {
154154 addRuleForVio ( frameconf , errors [ i ] )
155155 }
156- this . applyRules ( false , frameconf ) ;
156+ var myfilt = function ( frame , rule ) {
157+ if ( rule . errors ( ) ) {
158+ frame . errors = frame . errors ? frame . errors . concat ( rule . errors ( ) ) : rule . errors ( ) ;
159+ }
160+ }
161+ this . applyRules ( false , frameconf , myfilt ) ;
157162}
158163
159164DocumentFrame . prototype . clearErrors = function ( frameconf ) {
160- frameconf . all ( ) . errors ( false )
161- this . applyRules ( false , frameconf )
165+ frameconf . all ( )
166+ var myfilt = function ( frame , rule ) {
167+ if ( frame . errors ) delete ( frame . errors )
168+ }
169+ this . applyRules ( false , frameconf , myfilt )
170+ frameconf . rules = [ ]
162171}
163172
164173function addRuleForVio ( docview , error ) {
165- let prop = ( error [ 'api:property' ] ? error [ 'api:property' ] [ "@value" ] : false )
166- let subj = ( error [ 'api:subject' ] ? error [ 'api:subject' ] [ "@value" ] : false )
167- let val = ( error [ 'api:value' ] ? error [ 'api:value' ] [ "@value" ] : false )
168- let type = ( error [ 'api:type' ] ? error [ 'api:type' ] [ "@value" ] : false )
174+ let prop = ( error [ 'vio:property' ] ? error [ 'vio:property' ] [ "@value" ] : false )
175+ let subj = ( error [ 'vio:subject' ] ? error [ 'vio:subject' ] [ "@value" ] : false )
176+ let msg = ( error [ 'vio:message' ] ? error [ 'vio:message' ] [ "@value" ] : false )
177+ let val = ( error [ 'api:value' ] ? error [ 'api:value' ] : false )
178+ if ( val && val [ 0 ] == '"' && val [ val . length - 1 ] == '"' )
179+ val = val . substring ( 1 , val . length - 1 )
180+ let type = ( error [ 'api:type' ] ? error [ 'api:type' ] : false )
169181 if ( type && val ) { //api:BadCast
170- docview . data ( ) . value ( val ) . range ( type ) . errors ( [ error ] )
182+ docview . data ( ) . value ( val ) . type ( type ) . errors ( [ error ] )
183+ }
184+ if ( prop && subj ) { //untypedInstanceViolation
185+ let shrt = FrameHelper . shorten ( subj )
186+ if ( shrt . substring ( 0 , 5 ) == "woql:" ) shrt == shrt . substring ( 5 )
187+ docview . data ( ) . property ( prop ) . value ( shrt , subj ) . errors ( [ error ] )
171188 }
172189}
173190
0 commit comments