@W-19976108: Implement Faker and Plugin Validations#1105
Merged
vsbharath merged 1 commit intoNov 7, 2025
Conversation
vsbharath
approved these changes
Nov 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR adds semantic validation for Faker provider calls and three core plugins (Counters, UniqueId, and StatisticalDistributions). Users now get immediate feedback on invalid Faker methods, incorrect parameters, and plugin configuration errors—all before data generation begins.
✨ What's New
1. Faker Method Validation (Introspection-Based)
Added
FakerValidatorsclass that uses Python'sinspectmodule to validate Faker provider calls:first_name?")Example:
2. Plugin Validators
Counters Plugin
NumberCounter(start=1, step=1, name=None, parent=None)Errors (❌):
startmust be an integerstepmust be an integerstepcannot be zeroWarnings (⚠️ ):
nameshould be a string (type mismatch)DateCounter(start_date, step, name=None, parent=None)Errors (❌):
start_datestepstart_datemust be parseable as a datestepmust be a stringstepformat invalid (expects+/-<number><unit>like+1d,-1w,+1M,+1y)Warnings (⚠️ ):
nameshould be a string (type mismatch)UniqueId Plugin
NumericIdGenerator(template=None)Errors (❌):
templatemust be a stringpid,context,index, or numeric values allowed)Warnings (⚠️ ):
AlphaCodeGenerator(template, alphabet, min_chars, randomize_codes)Errors (❌):
pid,context,index, or numeric values allowed)alphabetmust be a stringalphabetmust have at least 2 charactersalphabettoo small for randomization (needs at least 6 chars whenrandomize_codes=True)min_charsmust be an integermin_charsmust be positiverandomize_codesmust be a booleanWarnings (⚠️ ):
StatisticalDistributions Plugin
Common to all distributions:
seedmust be an integer (if provided)normal(loc=0.0, scale=1.0, seed=None)Errors (❌):
locmust be numeric (int or float)scalemust be numeric (int or float)scalemust be positivelognormal(mean=0.0, sigma=1.0, seed=None)Errors (❌):
meanmust be numeric (int or float)sigmamust be numeric (int or float)sigmamust be positivebinomial(n, p, seed=None)Errors (❌):
npnmust be an integernmust be positivepmust be numeric (int or float)pmust be between 0.0 and 1.0exponential(scale=1.0, seed=None)Errors (❌):
scalemust be numeric (int or float)scalemust be positivepoisson(lam, seed=None)Errors (❌):
lamlammust be numeric (int or float)lammust be positivegamma(shape, scale, seed=None)Errors (❌):
shapescaleshapemust be numeric (int or float)shapemust be positivescalemust be numeric (int or float)scalemust be positive🔍 Implementation Highlights
Introspection-Based Validation
The Faker validator uses Python's
inspect.signature()to automatically validate any Faker provider without manual maintenance:This approach scales automatically as Faker providers are updated or added.
Co-located Validators
Validators live alongside their runtime implementations following the established pattern:
This co-location makes the code easy to discover and maintain.