spiral-project / daybed

Form validation and data storage API
http://daybed.rtfd.org/
BSD 3-Clause "New" or "Revised" License
53 stars 8 forks source link

Define the id syntax #196

Closed Natim closed 9 years ago

Natim commented 9 years ago

I have the following model:

{
  "definition": {
    "title": "Mobile Originated Numbers",
    "description": "Associate a country code to a number",
    "fields": [
      {
        "name": "mcc",
        "label": "Mobile Country Code",
        "type": "regex",
        "regex": "^[0-9]{3}$",
        "required": true
      },
      {
        "name": "mnc",
        "label": "Mobile Network Code",
        "type": "regex",
        "regex": "^[0-9]{2,3}$"
      },
      {
        "name": "moVerifier",
        "label": "MO Verifier Number",
        "type": "string",
        "required": true
      }
    ]
  }
}

I wish to define the id as the concatenation of MCC and MNC with MNC blank if not present. Also it could just be an id fields that would be validated with a regexp.

almet commented 9 years ago

I don't think we want to support such complicated use cases: since you have the regexps, I guess you should just use them and define a new field.

Natim commented 9 years ago

I did it differently finally: https://github.com/mozilla-services/msisdn-gateway/blob/1035666-msisdn-redis-map/msisdn-gateway/sms/infos/redis.js#L31L48