Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Access _validatorDefinitions for my custom item?

    I'm writing out code for a custom item:
    Code:
    isc.ClassFactory.defineClass("ArrayItem","TextItem");
    which is intended to be a container of FormItem objects displayed in a single text field. For example, I want an array of FloatItems. Rather than write my own isFloat validator, is there a safe way I can access:
    Code:
    _validatorDefinitions["isFloat"].condition
    for my own purposes? This sketch seems to work:
    Code:
    isc.ArrayItem.addProperties({
       validators: [
          {
             type:"custom",
             condition:function(item,validator,value,record){
                var valid = true;
                for(var i=0; i<value.length; i++){
                   for(var v=0; v<item.memberValidators.length; v++){
                      var mv = item.memberValidators[v];
                      valid &= isc.Validator.getValidatorDefinition(mv.type).condition({},mv,value[i]);
                   }
                }
                return valid;
             }
          }
       ]
    })
    which is using non-obfuscated but undocumented code, but it lets me make ArrayItems like this:
    Code:
    {type:"ArrayItem",
     memberValidators:[
         {type:"integerRange", min:1, max:100}
     ]
    });
    Is there a better approach than what I've outlined?
Working...
X