dataarts/tailbone

Add more validation options / rules

Closed this issue · 1 comments

The validation mechanism using the validation.json file is nice but the rules can only be regular expressions. I would propose some extra options / rules to be possible. The main thing missing now is a way to express REQUIRED attributes vs. optional ones.

Using this validation.json :

{
  "orders": {
    "reference": ".*",
    "status": "^CART|ORDERED|PAID|DELIVERED|ACTIVATED|FAILED|CANCELED$"
  }
}

we can add orders without a reference, but we like the make this a required attribute.
Maybe we can express this like this:

{
  "orders": {
    "reference": {"required": "true", "regex": ".*"}
    "status": { "required": "false", 
                    "default": "CART",
                    "regex": "^CART|ORDERED|PAID|DELIVERED|ACTIVATED|FAILED|CANCELED$"
    }
  }
}

also for numeric values a range (min: max) will be nice to express:

{
  "orders": {
    "reference": {"required": "true", "regex": ".*"}
    "amount": { "required": "true", 
                      "type": "integer",
                      "range": "150:9999",
                     }
  }
}

this would also allow better error messages like "amount 10000 exeeds maximum of 9999"

doug commented

validation can now be done in python with appengine_config.py