cerebral / cerebral-debugger

Debugger for Cerebral
http://cerebraljs.com/docs/introduction/debugger.html
MIT License
33 stars 16 forks source link

Regular expressions shown as {} in the state tree view #41

Closed joseds closed 5 years ago

joseds commented 6 years ago

Hi, the debugger (version 1.5.0) shows regular expressions used when defining Cerebral form validation as {} instead of showing the string representation.

Example:

  myForm: {
    salutationNameDE: {
      errorText: 'ungültig',
      isRequired: false,
      isValueRules: ['minLength:1'],
      validationRules: [/^[a-zA-ZäöüÄÖÜ0-9 ]*$/, 'maxLength: 10']
    }
  }

results in

  myForm: {
    salutationNameDE: {
      errorText: "ungültig",
      isRequired: false,
      isValueRules: ["minLength:1"],
      validationRules: [
        { },
        "maxLength: 10"
      ]
    }
  }

in the "STATE-TREE" debugger tab.

christianalfoni commented 5 years ago

Hm, this has to do with how JSON.stringify works. Regexps should ideally transform to its string representation on toJSON, but seems they do not. It would be quite an effort to make this work differently, too much for the gain I would state :)