Test-DbaDbDataGeneratorConfig
View SourceSynopsis
Validates JSON configuration files used for generating realistic test data in SQL Server databases
Description
Validates JSON configuration files created by New-DbaDbDataGeneratorConfig before using them with Invoke-DbaDbDataGenerator to populate tables with realistic fake data. The function performs comprehensive validation including checking for required column properties, verifying data types are supported, confirming masking types exist in the Bogus library, and validating subtypes are available.
This validation step prevents runtime errors during data generation and helps catch configuration issues early in the test data creation workflow. Returns detailed error information for any invalid configurations, showing exactly which tables and columns have problems so you can fix them before attempting to generate data.
Syntax
Test-DbaDbDataGeneratorConfig
[-FilePath] <String>
[-EnableException]
[<CommonParameters>]
Examples
Example: 1
PS > Test-DbaDbDataGeneratorConfig -FilePath C:\temp_datamasking\db1.json
Test the configuration file
Required Parameters
-FilePath
Specifies the path to the JSON configuration file created by New-DbaDbDataGeneratorConfig that needs validation.
Use this to verify your data generation configuration before running Invoke-DbaDbDataGenerator to avoid runtime errors.
| Property | Value |
|---|---|
| Alias | |
| Required | True |
| Pipeline | false |
| Default Value |
Optional Parameters
-EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value | False |
Outputs
PSCustomObject
Returns validation error objects for any configuration issues found. If the configuration file is valid with no errors, no output is returned.
Each error object contains the following properties:
- Table (string): Name of the table in the configuration where the error was found
- Column (string): Name of the column in the table where the error was found
- Value (string): The problematic value or comma-separated list of property names causing the error
- Error (string): Description of the validation error encountered
Common validation errors include:
- Missing required column properties (CharacterString, ColumnType, Composite, ForeignKey, Identity, MaskingType, MaxValue, MinValue, Name, Nullable, SubType)
- Additional properties in columns that are not in the required properties list
- Invalid column data types (unsupported by SQL Server or the Bogus data generation library)
- Invalid masking types (not available in the Bogus randomization library)
- Invalid masking subtypes (not available for the specified masking type) The validation errors help identify configuration issues before attempting to generate test data with Invoke-DbaDbDataGenerator, preventing runtime failures.
dbatools