Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nullable properties to json spec #2

Open
craig-davis opened this issue Jun 11, 2016 · 0 comments
Open

Add nullable properties to json spec #2

craig-davis opened this issue Jun 11, 2016 · 0 comments

Comments

@craig-davis
Copy link
Contributor

Feature

Allow nullable properties in a Specter file, with syntax influenced by the nullable type RFC. In the example below, the jobTitle is considered nullable.

{
  "__specter": "Sample customer record",
  "id": "@randomDigitNotNull@",
  "fname": "@firstName@",
  "lname": "@lastName@",
  "company": "@company@",
  "jobTitle": "?@jobTitle@"
}

Implementation

For property values prepended with a question mark ?, the generator will return either the result of the faker generator or a null value for some percentage of the results. The result must respect the seed value so that the results are repeatable. For string values, the return should be a null rather than an empty string.

The percentage of null returns is up for debate. I think 25% is a reasonable starting point.

Scope

This does not implement optional properties - where a property 'jobTitle' might be missing from the result altogether. This only addresses optional values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant