File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,8 @@ var (
120120 "excludesrune" : excludesRune ,
121121 "startswith" : startsWith ,
122122 "endswith" : endsWith ,
123+ "startsnotwith" : startsNotWith ,
124+ "endsnotwith" : endsNotWith ,
123125 "isbn" : isISBN ,
124126 "isbn10" : isISBN10 ,
125127 "isbn13" : isISBN13 ,
@@ -690,6 +692,16 @@ func endsWith(fl FieldLevel) bool {
690692 return strings .HasSuffix (fl .Field ().String (), fl .Param ())
691693}
692694
695+ // StartsNotWith is the validation function for validating that the field's value does not start with the text specified within the param.
696+ func startsNotWith (fl FieldLevel ) bool {
697+ return ! startsWith (fl )
698+ }
699+
700+ // EndsNotWith is the validation function for validating that the field's value does not end with the text specified within the param.
701+ func endsNotWith (fl FieldLevel ) bool {
702+ return ! endsWith (fl )
703+ }
704+
693705// FieldContains is the validation function for validating if the current field's value contains the field specified by the param's value.
694706func fieldContains (fl FieldLevel ) bool {
695707 field := fl .Field ()
Original file line number Diff line number Diff line change @@ -814,6 +814,18 @@ This validates that a string value ends with the supplied string value
814814
815815 Usage: endswith=goodbye
816816
817+ Does Not Start With
818+
819+ This validates that a string value does not start with the supplied string value
820+
821+ Usage: startsnotwith=hello
822+
823+ Does Not End With
824+
825+ This validates that a string value does not end with the supplied string value
826+
827+ Usage: endsnotwith=goodbye
828+
817829International Standard Book Number
818830
819831This validates that a string value contains a valid isbn10 or isbn13 value.
You can’t perform that action at this time.
0 commit comments