Closed marcsantiago closed 6 years ago
Thank you!
@marcsantiago could you please take a look at unit tests?
./validator.go:1202:26: invalid argument customErrorMessage (type tagOption) for len
./validator.go:1225:45: cannot use customErrorMessage (type tagOption) as type string in argument to fmt.Errorf
./validator.go:1225:95: too few values in struct initializer
./validator.go:1228:127: too few values in struct initializer
./validator.go:1230:130: too few values in struct initializer
FAIL github.com/asaskevich/govalidator [build failed]
Of course, sorry about that, I'll give it a look today.
Interesting, all my test pass locally and I've been using my fork in production since the PR
=== RUN TestEach === PAUSE TestEach === RUN TestMap === PAUSE TestMap === RUN TestFind === PAUSE TestFind === RUN TestFilter === PAUSE TestFilter === RUN TestCount === PAUSE TestCount === RUN TestToInt --- PASS: TestToInt (0.00s) === RUN TestToBoolean --- PASS: TestToBoolean (0.00s) === RUN TestToString --- PASS: TestToString (0.00s) === RUN TestToFloat --- PASS: TestToFloat (0.00s) === RUN TestToJSON --- PASS: TestToJSON (0.00s) === RUN TestErrorsToString === PAUSE TestErrorsToString === RUN TestAbs === PAUSE TestAbs === RUN TestSign === PAUSE TestSign === RUN TestIsNegative === PAUSE TestIsNegative === RUN TestIsNonNegative === PAUSE TestIsNonNegative === RUN TestIsPositive === PAUSE TestIsPositive === RUN TestIsNonPositive === PAUSE TestIsNonPositive === RUN TestIsWhole === PAUSE TestIsWhole === RUN TestIsNatural === PAUSE TestIsNatural === RUN TestInRangeInt === PAUSE TestInRangeInt === RUN TestInRangeFloat32 === PAUSE TestInRangeFloat32 === RUN TestInRangeFloat64 === PAUSE TestInRangeFloat64 === RUN TestInRange === PAUSE TestInRange === RUN TestContains === PAUSE TestContains === RUN TestMatches === PAUSE TestMatches === RUN TestLeftTrim === PAUSE TestLeftTrim === RUN TestRightTrim === PAUSE TestRightTrim === RUN TestTrim === PAUSE TestTrim === RUN TestWhiteList === PAUSE TestWhiteList === RUN TestBlackList === PAUSE TestBlackList === RUN TestStripLow === PAUSE TestStripLow === RUN TestReplacePattern === PAUSE TestReplacePattern === RUN TestEscape === PAUSE TestEscape === RUN TestUnderscoreToCamelCase === PAUSE TestUnderscoreToCamelCase === RUN TestCamelCaseToUnderscore === PAUSE TestCamelCaseToUnderscore === RUN TestReverse === PAUSE TestReverse === RUN TestGetLines === PAUSE TestGetLines === RUN TestGetLine === PAUSE TestGetLine === RUN TestRemoveTags === PAUSE TestRemoveTags === RUN TestSafeFileName === PAUSE TestSafeFileName === RUN TestNormalizeEmail === PAUSE TestNormalizeEmail === RUN TestTruncate === PAUSE TestTruncate === RUN TestPadLeft === PAUSE TestPadLeft === RUN TestPadRight === PAUSE TestPadRight === RUN TestPadBoth === PAUSE TestPadBoth === RUN TestIsAlpha === PAUSE TestIsAlpha === RUN TestIsUTFLetter === PAUSE TestIsUTFLetter === RUN TestIsAlphanumeric === PAUSE TestIsAlphanumeric === RUN TestIsUTFLetterNumeric === PAUSE TestIsUTFLetterNumeric === RUN TestIsNumeric === PAUSE TestIsNumeric === RUN TestIsUTFNumeric === PAUSE TestIsUTFNumeric === RUN TestIsUTFDigit === PAUSE TestIsUTFDigit === RUN TestIsLowerCase === PAUSE TestIsLowerCase === RUN TestIsUpperCase === PAUSE TestIsUpperCase === RUN TestHasLowerCase === PAUSE TestHasLowerCase === RUN TestHasUpperCase === PAUSE TestHasUpperCase === RUN TestIsInt === PAUSE TestIsInt === RUN TestIsHash === PAUSE TestIsHash === RUN TestIsExistingEmail === PAUSE TestIsExistingEmail === RUN TestIsEmail === PAUSE TestIsEmail === RUN TestIsURL === PAUSE TestIsURL === RUN TestIsRequestURL === PAUSE TestIsRequestURL === RUN TestIsRequestURI === PAUSE TestIsRequestURI === RUN TestIsFloat === PAUSE TestIsFloat === RUN TestIsHexadecimal === PAUSE TestIsHexadecimal === RUN TestIsHexcolor === PAUSE TestIsHexcolor === RUN TestIsRGBcolor === PAUSE TestIsRGBcolor === RUN TestIsNull === PAUSE TestIsNull === RUN TestIsDivisibleBy === PAUSE TestIsDivisibleBy === RUN TestIsByteLength === PAUSE TestIsByteLength === RUN TestIsJSON === PAUSE TestIsJSON === RUN TestIsMultibyte === PAUSE TestIsMultibyte === RUN TestIsASCII === PAUSE TestIsASCII === RUN TestIsPrintableASCII === PAUSE TestIsPrintableASCII === RUN TestIsFullWidth === PAUSE TestIsFullWidth === RUN TestIsHalfWidth === PAUSE TestIsHalfWidth === RUN TestIsVariableWidth === PAUSE TestIsVariableWidth === RUN TestIsUUID === PAUSE TestIsUUID === RUN TestIsCreditCard === PAUSE TestIsCreditCard === RUN TestIsISBN === PAUSE TestIsISBN === RUN TestIsDataURI === PAUSE TestIsDataURI === RUN TestIsBase64 === PAUSE TestIsBase64 === RUN TestIsBase64String === PAUSE TestIsBase64String === RUN TestIsBase64RawString === PAUSE TestIsBase64RawString === RUN TestIsISO3166Alpha2 === PAUSE TestIsISO3166Alpha2 === RUN TestIsISO3166Alpha3 === PAUSE TestIsISO3166Alpha3 === RUN TestIsISO693Alpha2 === PAUSE TestIsISO693Alpha2 === RUN TestIsISO693Alpha3b === PAUSE TestIsISO693Alpha3b === RUN TestIsIP === PAUSE TestIsIP === RUN TestIsPort === PAUSE TestIsPort === RUN TestIsDNSName === PAUSE TestIsDNSName === RUN TestIsHost === PAUSE TestIsHost === RUN TestIsDialString === PAUSE TestIsDialString === RUN TestIsMAC === PAUSE TestIsMAC === RUN TestFilePath === PAUSE TestFilePath === RUN TestIsLatitude === PAUSE TestIsLatitude === RUN TestIsLongitude === PAUSE TestIsLongitude === RUN TestIsSSN === PAUSE TestIsSSN === RUN TestIsMongoID === PAUSE TestIsMongoID === RUN TestIsSemver === PAUSE TestIsSemver === RUN TestIsTime === PAUSE TestIsTime === RUN TestIsRFC3339 === PAUSE TestIsRFC3339 === RUN TestIsISO4217 === PAUSE TestIsISO4217 === RUN TestByteLength === PAUSE TestByteLength === RUN TestRuneLength === PAUSE TestRuneLength === RUN TestStringLength === PAUSE TestStringLength === RUN TestIsIn === PAUSE TestIsIn === RUN TestValidateMissingValidationDeclarationStruct --- PASS: TestValidateMissingValidationDeclarationStruct (0.00s) === RUN TestFieldRequiredByDefault --- PASS: TestFieldRequiredByDefault (0.00s) === RUN TestMultipleFieldsRequiredByDefault --- PASS: TestMultipleFieldsRequiredByDefault (0.00s) === RUN TestFieldsRequiredByDefaultButExemptStruct --- PASS: TestFieldsRequiredByDefaultButExemptStruct (0.00s) === RUN TestFieldsRequiredByDefaultButExemptOrOptionalStruct --- PASS: TestFieldsRequiredByDefaultButExemptOrOptionalStruct (0.00s) === RUN TestInvalidValidator --- PASS: TestInvalidValidator (0.00s) === RUN TestCustomValidator --- PASS: TestCustomValidator (0.00s) === RUN TestStructWithCustomByteArray === PAUSE TestStructWithCustomByteArray === RUN TestValidateNegationStruct --- PASS: TestValidateNegationStruct (0.00s) === RUN TestLengthStruct --- PASS: TestLengthStruct (0.00s) === RUN TestStringLengthStruct --- PASS: TestStringLengthStruct (0.00s) === RUN TestStringMatchesStruct --- PASS: TestStringMatchesStruct (0.00s) === RUN TestIsInStruct --- PASS: TestIsInStruct (0.00s) === RUN TestRequiredIsInStruct --- PASS: TestRequiredIsInStruct (0.00s) === RUN TestEmptyRequiredIsInStruct --- PASS: TestEmptyRequiredIsInStruct (0.00s) === RUN TestFunkyIsInStruct --- PASS: TestFunkyIsInStruct (0.00s) === RUN TestValidateStruct --- PASS: TestValidateStruct (0.00s) === RUN TestRequired --- PASS: TestRequired (0.00s) === RUN TestErrorByField === PAUSE TestErrorByField === RUN TestErrorsByField === PAUSE TestErrorsByField === RUN TestValidateStructPointers --- PASS: TestValidateStructPointers (0.00s) === RUN TestValidateStructParamValidatorInt --- PASS: TestValidateStructParamValidatorInt (0.00s) === RUN TestIsCIDR === PAUSE TestIsCIDR === RUN TestOptionalCustomValidators --- PASS: TestOptionalCustomValidators (0.00s) === RUN TestJSONValidator --- PASS: TestJSONValidator (0.00s) === RUN TestValidatorIncludedInError --- PASS: TestValidatorIncludedInError (0.00s) === RUN TestIsRsaPublicKey --- PASS: TestIsRsaPublicKey (0.00s) === RUN TestInIntArr === PAUSE TestInIntArr === CONT TestEach === CONT TestIsExistingEmail --- PASS: TestEach (0.00s) === CONT TestReplacePattern === CONT TestReverse --- PASS: TestReverse (0.00s) === CONT TestIsEmail === CONT TestIsDNSName === CONT TestIsVariableWidth === CONT TestIsISO3166Alpha3 --- PASS: TestIsEmail (0.00s) === CONT TestIsBase64String --- PASS: TestIsBase64String (0.00s) === CONT TestIsDataURI --- PASS: TestIsISO3166Alpha3 (0.00s) === CONT TestIsISO3166Alpha2 --- PASS: TestReplacePattern (0.00s) === CONT TestIsBase64 === CONT TestIsUUID === CONT TestIsISBN --- PASS: TestIsVariableWidth (0.00s) --- PASS: TestIsISO3166Alpha2 (0.00s) === CONT TestIsCreditCard --- PASS: TestIsUUID (0.00s) === CONT TestIsBase64RawString --- PASS: TestIsDNSName (0.00s) === CONT TestIsFullWidth === CONT TestIsPrintableASCII --- PASS: TestIsFullWidth (0.00s) --- PASS: TestIsBase64RawString (0.00s) === CONT TestIsHexcolor === CONT TestIsASCII --- PASS: TestIsPrintableASCII (0.00s) === CONT TestIsJSON --- PASS: TestIsASCII (0.00s) === CONT TestIsMultibyte --- PASS: TestIsHexcolor (0.00s) === CONT TestIsByteLength --- PASS: TestIsJSON (0.00s) === CONT TestIsDivisibleBy === CONT TestIsRGBcolor --- PASS: TestIsMultibyte (0.00s) --- PASS: TestIsByteLength (0.00s) === CONT TestIsHalfWidth === CONT TestStructWithCustomByteArray === CONT TestInIntArr --- PASS: TestIsDataURI (0.00s) --- PASS: TestIsHalfWidth (0.00s) === CONT TestIsCIDR --- PASS: TestIsRGBcolor (0.00s) === CONT TestErrorsByField --- PASS: TestIsCIDR (0.00s) === CONT TestErrorByField --- PASS: TestIsISBN (0.00s) --- PASS: TestErrorByField (0.00s) === CONT TestByteLength --- PASS: TestInIntArr (0.00s) === CONT TestStringLength --- PASS: TestIsBase64 (0.00s) === CONT TestIsIn === CONT TestRuneLength --- PASS: TestIsIn (0.00s) === CONT TestIsTime --- PASS: TestByteLength (0.00s) === CONT TestIsISO4217 === CONT TestIsRFC3339 === CONT TestIsMAC --- PASS: TestStringLength (0.00s) --- PASS: TestRuneLength (0.00s) --- PASS: TestIsISO4217 (0.00s) === CONT TestIsMongoID --- PASS: TestIsMAC (0.00s) --- PASS: TestIsMongoID (0.00s) --- PASS: TestIsCreditCard (0.01s) === CONT TestIsSSN --- PASS: TestIsRFC3339 (0.00s) === CONT TestIsLongitude --- PASS: TestIsTime (0.00s) --- PASS: TestStructWithCustomByteArray (0.00s) === CONT TestFilePath --- PASS: TestErrorsByField (0.00s) === CONT TestIsFloat === CONT TestIsNull === CONT TestIsLatitude === CONT TestIsHexadecimal --- PASS: TestIsDivisibleBy (0.00s) --- PASS: TestIsFloat (0.00s) === CONT TestIsAlphanumeric === CONT TestIsInt --- PASS: TestIsLongitude (0.00s) === CONT TestIsHash --- PASS: TestIsNull (0.00s) === CONT TestHasLowerCase --- PASS: TestIsInt (0.00s) === CONT TestIsUpperCase --- PASS: TestIsHexadecimal (0.00s) === CONT TestHasUpperCase --- PASS: TestIsUpperCase (0.00s) === CONT TestIsUTFNumeric === CONT TestIsLowerCase --- PASS: TestHasLowerCase (0.00s) --- PASS: TestIsLowerCase (0.00s) --- PASS: TestIsLatitude (0.00s) === CONT TestIsUTFDigit --- PASS: TestIsSSN (0.00s) --- PASS: TestIsAlphanumeric (0.00s) --- PASS: TestIsUTFNumeric (0.00s) === CONT TestIsNumeric === CONT TestIsUTFLetterNumeric === CONT TestIsUTFLetter === CONT TestIsHost === CONT TestIsDialString --- PASS: TestIsUTFLetterNumeric (0.00s) --- PASS: TestIsUTFDigit (0.00s) === CONT TestIsPort === CONT TestRemoveTags --- PASS: TestIsNumeric (0.00s) --- PASS: TestIsPort (0.00s) === CONT TestPadRight === CONT TestIsAlpha === CONT TestPadBoth --- PASS: TestPadRight (0.00s) --- PASS: TestIsUTFLetter (0.00s) --- PASS: TestHasUpperCase (0.00s) --- PASS: TestIsDialString (0.00s) --- PASS: TestPadBoth (0.00s) === CONT TestPadLeft --- PASS: TestIsAlpha (0.00s) === CONT TestSafeFileName === CONT TestIsURL --- PASS: TestPadLeft (0.00s) === CONT TestTruncate --- PASS: TestRemoveTags (0.00s) === CONT TestIsRequestURL === CONT TestIsWhole --- PASS: TestIsRequestURL (0.00s) === CONT TestLeftTrim --- PASS: TestIsWhole (0.00s) === CONT TestInRange --- PASS: TestLeftTrim (0.00s) === CONT TestIsSemver --- PASS: TestInRange (0.00s) --- PASS: TestTruncate (0.00s) === CONT TestContains === CONT TestInRangeFloat64 --- PASS: TestIsSemver (0.00s) === CONT TestTrim --- PASS: TestInRangeFloat64 (0.00s) --- PASS: TestContains (0.00s) === CONT TestBlackList === CONT TestStripLow --- PASS: TestSafeFileName (0.00s) --- PASS: TestIsHost (0.00s) === CONT TestInRangeInt --- PASS: TestTrim (0.00s) === CONT TestIsNatural === CONT TestGetLines --- PASS: TestIsNatural (0.00s) === CONT TestNormalizeEmail === CONT TestGetLine --- PASS: TestBlackList (0.00s) === CONT TestWhiteList --- PASS: TestIsHash (0.01s) === CONT TestIsRequestURI --- PASS: TestGetLines (0.00s) --- PASS: TestGetLine (0.00s) --- PASS: TestIsRequestURI (0.00s) === CONT TestRightTrim --- PASS: TestInRangeInt (0.00s) === CONT TestIsNonNegative === CONT TestIsPositive --- PASS: TestIsNonNegative (0.00s) --- PASS: TestStripLow (0.00s) === CONT TestIsNonPositive --- PASS: TestIsPositive (0.00s) === CONT TestInRangeFloat32 === CONT TestIsISO693Alpha3b --- PASS: TestWhiteList (0.00s) === CONT TestSign --- PASS: TestIsNonPositive (0.00s) --- PASS: TestSign (0.00s) === CONT TestIsNegative --- PASS: TestInRangeFloat32 (0.00s) === CONT TestIsIP === CONT TestCamelCaseToUnderscore --- PASS: TestIsNegative (0.00s) --- PASS: TestCamelCaseToUnderscore (0.00s) --- PASS: TestRightTrim (0.00s) === CONT TestFilter === CONT TestIsISO693Alpha2 --- PASS: TestFilter (0.00s) === CONT TestUnderscoreToCamelCase --- PASS: TestIsISO693Alpha3b (0.00s) --- PASS: TestIsIP (0.00s) === CONT TestEscape === CONT TestFind --- PASS: TestUnderscoreToCamelCase (0.00s) === CONT TestCount --- PASS: TestFind (0.00s) --- PASS: TestEscape (0.00s) === CONT TestAbs --- PASS: TestIsISO693Alpha2 (0.00s) === CONT TestMap --- PASS: TestAbs (0.00s) === CONT TestMatches === CONT TestErrorsToString --- PASS: TestCount (0.00s) --- PASS: TestNormalizeEmail (0.00s) --- PASS: TestMap (0.00s) --- PASS: TestErrorsToString (0.00s) --- PASS: TestMatches (0.00s) --- PASS: TestIsURL (0.03s) --- PASS: TestFilePath (0.17s) --- PASS: TestIsExistingEmail (0.73s) PASS ok github.com/marcsantiago/govalidator (cached)
@marcsantiago which Go version are you using? Tests are falling at golang:1.9
go version go1.10.2 darwin/amd64
I think the fails are unrelated to the PR, if you diff the changes customErrorMessage was never touched, in fact every change is additive with thier own tests... with the exception of println to fmt.Println in the validator_test.go file
The current base64 validator makes a few assumptions about the nature of the base 64 string as a result of using regex. By using Go's build in base64 lib we circumvent the regex as well as adding full functionally to validate both standard base64 strings and raw base64 strings. This is an additive string, which allows for full backwards capabilities.
(Enhancement) Validator: Validating contents of []int … Adding a new type to enable the ability to validate what's inside of an int slice. This is important for structured API documentation, when the items in the slice should be known integers. I didn't implement the other slice types as I don't have a use case for them, but it should be easy enough to extend. This is not a breaking change.