@@ -141,14 +141,37 @@ DocumentFrame.prototype.filterFrame = function(loadRenderer){
141
141
frame . compare = rule . compare ( ) ;
142
142
}
143
143
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
146
147
}
147
148
this . applyRules ( false , false , myfilt ) ;
148
149
}
149
150
151
+ DocumentFrame . prototype . setErrors = function ( errors , frameconf ) {
152
+ this . clearErrors ( frameconf )
153
+ for ( var i = 0 ; i < errors . length ; i ++ ) {
154
+ addRuleForVio ( frameconf , errors [ i ] )
155
+ }
156
+ this . applyRules ( false , frameconf ) ;
157
+ }
158
+
159
+ DocumentFrame . prototype . clearErrors = function ( frameconf ) {
160
+ frameconf . all ( ) . errors ( false )
161
+ this . applyRules ( false , frameconf )
162
+ }
163
+
164
+ function 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 )
169
+ if ( type && val ) { //api:BadCast
170
+ docview . data ( ) . value ( val ) . range ( type ) . errors ( [ error ] )
171
+ }
172
+ }
150
173
151
- /*
174
+ /*"
152
175
* adds render and compare functions to object frames
153
176
*/
154
177
DocumentFrame . prototype . applyRules = function ( doc , config , mymatch ) {
0 commit comments