Rename ValidatorRegexp to CaptureRegexp
This commit is contained in:
parent
e472b482d6
commit
78189aab37
5 changed files with 58 additions and 58 deletions
|
|
@ -730,7 +730,7 @@ type uploadedFlag struct {
|
|||
IgnoreCase bool
|
||||
Multiline bool
|
||||
NoTrim bool
|
||||
ValidatorRe *string `json:"validator_regexp"`
|
||||
CaptureRe *string `json:"validator_regexp"`
|
||||
SortReGroups bool `json:"sort_re_grps"`
|
||||
Flag string
|
||||
Value []byte
|
||||
|
|
@ -752,8 +752,8 @@ func createExerciceFlag(c *gin.Context) {
|
|||
}
|
||||
|
||||
var vre *string = nil
|
||||
if uk.ValidatorRe != nil && len(*uk.ValidatorRe) > 0 {
|
||||
vre = uk.ValidatorRe
|
||||
if uk.CaptureRe != nil && len(*uk.CaptureRe) > 0 {
|
||||
vre = uk.CaptureRe
|
||||
}
|
||||
|
||||
exercice := c.MustGet("exercice").(*fic.Exercice)
|
||||
|
|
@ -842,10 +842,10 @@ func updateExerciceFlag(c *gin.Context) {
|
|||
flag.ChoicesCost = uk.ChoicesCost
|
||||
flag.BonusGain = uk.BonusGain
|
||||
|
||||
if uk.ValidatorRe != nil && len(*uk.ValidatorRe) > 0 {
|
||||
flag.ValidatorRegexp = uk.ValidatorRe
|
||||
if uk.CaptureRe != nil && len(*uk.CaptureRe) > 0 {
|
||||
flag.CaptureRegexp = uk.CaptureRe
|
||||
} else {
|
||||
flag.ValidatorRegexp = nil
|
||||
flag.CaptureRegexp = nil
|
||||
}
|
||||
|
||||
if _, err := flag.Update(); err != nil {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Reference in a new issue