Skip to content

Constant Generator

This generator simply generates a deep copy of the value specified in the configuration.

As the given value in the configuration, you can use whatever value you need - string, number, array, object, array of objects, undefined or null.

Examples

1
2
3
4
5
6
7
const config: ConstantValueConfig = {
    value: 'my constant value'
}

const generator = new ConstantValue(config);

console.log(generator.generate());

Output

'my constant value'
1
2
3
4
5
6
7
const config: ConstantValueConfig = {
    value: 'my constant value'
}

const generator = getValueGenerator('constant-value', config);

console.log(generator.generate());

Output

'my constant value'
const schema: SchemaInput = {
    fields: {
        value: {
            type: 'constant-value',
            config: {
                value: 'my constant value'
            }
        }
    }
}

const fabricator = new Fabricator(schema);

console.log(fabricator.generate());

Output

{ value: 'my constant value' }