File tree Expand file tree Collapse file tree 3 files changed +6
-3
lines changed
Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ func (p Param) Render() huh.Field {
2020 if p .Required {
2121 group = append (group , validators .Required (p .Name , p .Trim ))
2222 }
23- if p .MinLength != nil {
23+ // if the value is not required and no value has been given, min length validator should be ignored.
24+ if p .Required && p .MinLength != nil {
2425 group = append (group , validators .MinLength (* p .MinLength ))
2526 }
2627 if p .MaxLength != nil {
Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ func (p Param) RenderInput() *huh.Input {
3939 if p .Required {
4040 group = append (group , validators .Required (p .Name , p .Trim ))
4141 }
42- if p .MinLength != nil {
42+ // if the value is not required and no value has been given, min length validator should be ignored.
43+ if p .Required && p .MinLength != nil {
4344 group = append (group , validators .MinLength (* p .MinLength ))
4445 }
4546 if p .MaxLength != nil {
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ func (p Param) Render() huh.Field {
3737 if p .Required {
3838 group = append (group , validators .Required (p .Name , false ))
3939 }
40- if p .MinLength != nil {
40+ // if the value is not required and no value has been given, min length validator should be ignored.
41+ if p .Required && p .MinLength != nil {
4142 group = append (group , validators .MinLength (* p .MinLength ))
4243 }
4344 if p .MaxLength != nil {
You can’t perform that action at this time.
0 commit comments