accordproject / concerto

Business schema language and runtime
https://concerto.accordproject.org
Apache License 2.0
105 stars 99 forks source link

Factory doesn't generate empty entities #844

Open ekarademir opened 3 months ago

ekarademir commented 3 months ago

Factory class advertises an option to generate empty entity instead of a "sample", however the option has no effect

Bug Report 🐛

As it's being used by the CLI generate command here, and being passed onto the factory class here, there should be an option to generate empty objects as advertised here.

But that option is simply being ignored.

Expected Behavior

That the factory returns an entity with empty values

Current Behavior

Returns sampled data as values

Possible Solution

Steps to Reproduce

  1. Use the setup outlined in the CLI command.
  2. Inspect the JSON document

Context (Environment)

Desktop

Detailed Description

Possible Implementation

mttrbrts commented 2 months ago

@ekarademir do the String properties in your model have min/max length validators?

We made the decision when adding those that the output of the value generators should always be a valid instance. This forces us to generate some sample data even when using the empty mode.

I think that there's scope to improve the logic here, for example: