[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 package customValidators 2 { 3 import com.adobe.serialization.json.JSON; 4 import com.adobe.serialization.json.JSONParseError; 5 6 import mx.validators.ValidationResult; 7 import mx.validators.Validator; 8 9 import nl.demonsters.debugger.MonsterDebugger; 10 11 public class JSONValidator extends Validator 12 { 13 // Define Array for the return value of doValidation(). 14 private var errors:Array; 15 16 public function JSONValidator() 17 { 18 super(); 19 } 20 21 override protected function doValidation(value:Object):Array { 22 var JSONstring:String = String(value); 23 errors = []; 24 if (JSONstring != ''){ 25 try { 26 JSON.decode(JSONstring); 27 } catch (err:Error){ 28 errors.push(new ValidationResult(true, null, "JSON decode failed", 29 "Not able to decode this JSON.")); 30 } 31 } 32 if (this.required && JSONstring == ''){ 33 errors.push(new ValidationResult(true, null, "Required", 34 "You must enter a value for this argument - for a string argument an empty string can be entered as \"\" or you can disable an optional argument.")); 35 } 36 return errors; 37 } 38 39 } 40 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |