@@ -232,7 +232,7 @@ type Validations struct {
232
232
233
233
// Variables holds any variables which must be generated to perform
234
234
// validation. Variables are not permitted in every context.
235
- Variables []VariableGen
235
+ Variables []* VariableGen
236
236
237
237
// Comments holds comments to emit (without the leanding "//").
238
238
Comments []string
@@ -263,7 +263,7 @@ func (v *Validations) AddFunction(f FunctionGen) {
263
263
v .Functions = append (v .Functions , f )
264
264
}
265
265
266
- func (v * Validations ) AddVariable (variable VariableGen ) {
266
+ func (v * Validations ) AddVariable (variable * VariableGen ) {
267
267
v .Variables = append (v .Variables , variable )
268
268
}
269
269
@@ -325,20 +325,6 @@ type Identifier types.Name
325
325
// PrivateVars are generated using the PrivateNamer strategy.
326
326
type PrivateVar types.Name
327
327
328
- // VariableGen provides validation-gen with the information needed to generate variable.
329
- // Variables typically support generated functions by providing static information such
330
- // as the list of supported symbols for an enum.
331
- type VariableGen interface {
332
- // TagName returns the tag which triggers this validator.
333
- TagName () string
334
-
335
- // Var returns the variable identifier.
336
- Var () PrivateVar
337
-
338
- // Init generates the function call that the variable is assigned to.
339
- Init () FunctionGen
340
- }
341
-
342
328
// Function creates a FunctionGen for a given function name and extraArgs.
343
329
func Function (tagName string , flags FunctionFlags , function types.Name , extraArgs ... any ) FunctionGen {
344
330
return FunctionGen {
@@ -405,28 +391,19 @@ func (fg FunctionGen) WithComment(comment string) FunctionGen {
405
391
}
406
392
407
393
// Variable creates a VariableGen for a given function name and extraArgs.
408
- func Variable (variable PrivateVar , init FunctionGen ) VariableGen {
409
- return & variableGen {
410
- variable : variable ,
411
- init : init ,
394
+ func Variable (variable PrivateVar , initFunc FunctionGen ) * VariableGen {
395
+ return & VariableGen {
396
+ Variable : variable ,
397
+ InitFunc : initFunc ,
412
398
}
413
399
}
414
400
415
- type variableGen struct {
416
- variable PrivateVar
417
- init FunctionGen
418
- }
419
-
420
- func (v variableGen ) TagName () string {
421
- return v .init .TagName
422
- }
423
-
424
- func (v variableGen ) Var () PrivateVar {
425
- return v .variable
426
- }
401
+ type VariableGen struct {
402
+ // Variable holds the variable identifier.
403
+ Variable PrivateVar
427
404
428
- func ( v variableGen ) Init () FunctionGen {
429
- return v . init
405
+ // InitFunc describes the function call that the variable is assigned to.
406
+ InitFunc FunctionGen
430
407
}
431
408
432
409
// WrapperFunction describes a function literal which has the fingerprint of a
0 commit comments