Rename ValidatorRegexp to CaptureRegexp

This commit is contained in:
nemunaire 2023-05-16 09:59:59 +02:00
commit 78189aab37
5 changed files with 58 additions and 58 deletions

View file

@ -46,8 +46,8 @@ type ExerciceFlag struct {
Ordered bool `toml:",omitempty"`
CaseSensitive bool `toml:",omitempty"`
NoTrim bool `toml:",omitempty"`
ValidatorRe string `toml:"validator_regexp,omitempty"`
SortReGroups bool `toml:"sort_validator_regexp_groups,omitempty"`
CaptureRe string `toml:"capture_regexp,omitempty"`
SortReGroups bool `toml:"sort_capture_regexp_groups,omitempty"`
Placeholder string `toml:",omitempty"`
Help string `toml:",omitempty"`
BonusGain int32 `toml:"bonus_gain,omitempty"`
@ -143,7 +143,7 @@ func getExerciceParams(i Importer, exercice *fic.Exercice) (params ExerciceParam
Label: flag.Label,
Type: "ucq",
Raw: flag.Raw,
ValidatorRe: flag.ValidatorRe,
CaptureRe: flag.CaptureRe,
Placeholder: flag.Placeholder,
ChoicesCost: flag.ChoicesCost,
Choice: flag.Choice,

View file

@ -160,7 +160,7 @@ func buildKeyFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, defau
flag.Label = flag.Label[1:]
}
raw, prep, terrs := getRawKey(flag.Raw, flag.ValidatorRe, flag.Ordered, flag.ShowLines, flag.Separator)
raw, prep, terrs := getRawKey(flag.Raw, flag.CaptureRe, flag.Ordered, flag.ShowLines, flag.Separator)
if len(terrs) > 0 {
for _, terr := range terrs {
@ -175,26 +175,26 @@ func buildKeyFlag(exercice *fic.Exercice, flag ExerciceFlag, flagline int, defau
errs = append(errs, NewFlagError(exercice, &flag, flagline, fmt.Errorf("WARNING non-printable characters in flag, is this really expected?")))
}
hashedFlag, err := fic.ComputeHashedFlag([]byte(raw), !flag.CaseSensitive, flag.NoTrim, validatorRegexp(flag.ValidatorRe), flag.SortReGroups)
hashedFlag, err := fic.ComputeHashedFlag([]byte(raw), !flag.CaseSensitive, flag.NoTrim, validatorRegexp(flag.CaptureRe), flag.SortReGroups)
if err != nil {
errs = append(errs, NewFlagError(exercice, &flag, flagline, err))
return
}
fk := &fic.FlagKey{
Type: flag.Type,
IdExercice: exercice.Id,
Order: int8(flagline),
Label: flag.Label,
Placeholder: flag.Placeholder,
Help: flag.Help,
Unit: flag.Unit,
IgnoreCase: !flag.CaseSensitive,
Multiline: flag.Type == "text",
ValidatorRegexp: validatorRegexp(flag.ValidatorRe),
SortReGroups: flag.SortReGroups,
Checksum: hashedFlag[:],
ChoicesCost: flag.ChoicesCost,
BonusGain: flag.BonusGain,
Type: flag.Type,
IdExercice: exercice.Id,
Order: int8(flagline),
Label: flag.Label,
Placeholder: flag.Placeholder,
Help: flag.Help,
Unit: flag.Unit,
IgnoreCase: !flag.CaseSensitive,
Multiline: flag.Type == "text",
CaptureRegexp: validatorRegexp(flag.CaptureRe),
SortReGroups: flag.SortReGroups,
Checksum: hashedFlag[:],
ChoicesCost: flag.ChoicesCost,
BonusGain: flag.BonusGain,
}
// Call checks hooks