Skip to content

Releases: go-goyave/goyave

Release v4.1.0

09 Mar 09:50
b7dd283
Compare
Choose a tag to compare
  • Added database.SetConnection().
  • Added support for raw queries in database.Paginator.

Release v4.0.0

14 Jan 15:12
6558f4e
Compare
Choose a tag to compare
  • Only the last two major versions of Go will be supported, starting with this release.

Motivation: Supporting only the last two minor versions of the language follows Google's policy and allows for development of new modern features. It lets the framework be updated without it being considered a breaking change, and encourages to not use outdated versions of the language while newer ones contain security fixes.

  • Validation changes
    • Added validation rules before_now and after_now.
    • Added validation RuleSet and Rules composition for re-usability of redundant validated objects.
    • Changed signature of validation.RuleFunc to func(*validation.Context) bool. validation.Context provides more information and a cleaner and more flexible API.
      • Note: Converting rules now modify context.Value instead of directly modifying the input data.
    • Improved n-dimensional array validation with a new syntax.
      • The chevron-based syntax disappears in favor of a new more idiomatic syntax based on the name of the field, for example array[] will validate all the elements of the array array.
      • This new syntax allows for the validation of objects inside arrays.
    • Improved tree-like validation error messages structure, identifying precisely each element based on the expected structure. This structure also identifies each array element precisely with its index.
    • Removed the confirmed validation rule. Use same:path.to.field instead.
    • If a field is missing and not required, child fields are now skipped. This prevents required rules to not pass if the parent is not required and missing.
    • The required rules now allows empty strings.
    • Use *validation.Context in validation message placeholders. The validation.Placeholder signatures becomes func(fieldName string, language string, ctx *validation.Context) string.
    • Added Extra (map[string]interface{}) to *validation.Context. This allows placeholders to use additional information given by the validator function.
    • Added validation.StructList. This acts as a better alternative syntax for validation. The previous alternative syntax (*validation.Rules) should not be used for validation rules definition anymore but still works.

Motivation: Although the validation package has seen some major improvements in v3, it was still far from perfect and was really lacking some important capabilities, such as the validation of objects in arrays. The array validation syntax was confusing, hard to read, and incompatible with the new syntax that was needed for object validation in arrays. We now have a more readable syntax, offering better capabilities. Because of how differently the validator works internally, we also had the opportunity to rework the error messages output, which now offers an impressive degree of precision. Precision in error messages gives a real edge over competing validation libraries.

  • Refactored the helper package and split it into several focused packages.
    • helper/filesystem moved to util/fsutil
    • helper/walk moved to util/walk
    • New package util/httputil
      • Contains ParseMultiValuesHeader() and HeaderValue
    • New package util/reflectutil
      • Contains Only()
    • New package util/sliceutil
      • Contains IndexOf(), IndexOfStr(), Contains(), ContainsStr() and Equal() (previously named SliceEqual())
    • New package util/sqlutil
      • Contains EscapeLike()
    • New package util/typeutil
      • Contains Map, ToFloat64(), ToString()

Motivation: The helper packaged started to become more and more bloated with functions for things unrelated to each other. To make this part of the code more idiomatic and expressive, the decision to split the package in several parts and re-think the naming was taken.

  • Removed model:"hide" because it was redundant with json:"-".
  • Added goyave.ProxyBaseURL() and server.proxy configuration entries.
  • Added global middleware. Global middleware are executed on all requests, including requests that don't match any route or that result in "Method Not Allowed". This allows for better logging, rate limiting, and more, while keeping the already existing tools.
  • Added helper/walk package to navigate complex data structure of unknown type (map[string]interface{}). This is used by the validator.
  • Migrated from dgrijalva/jwt-go library to the maintained golang-jwt/jwt.
  • Added ability to set default language strings from code using lang.SetDefaultLine(), lang.SetDefaultValidationRule() and lang.SetDefaultFieldName().
  • JWT: now uses standard sub instead of userid by default.
  • Reduced the amount of reflection in auth.FindColums.
  • Added support for promoted pointer of struct in auth.FindColumns and helper.Only.
  • database.Paginator improvements
    • Now exports its DB field so it can be re-assigned with new clauses.
    • Now exports its UpdatePageInfo() method so it can be called manually before the real query.
    • Now uses a Gorm session for page info query to prevent weird queries in some specific scenarios.
    • Fields names are now in camel case when json marshalling a Paginator.
  • Removed the DisallowNonValidatedFields middleware as it would be too expensive and complex to properly implement it with the new validation system.
  • Removed the unused name parameter in request.Cookie(). Thanks to @agbaraka for the contribution!
  • Fixed duplicate error message when a request accessor panicked.

Pre-release v4.0.0-rc3

27 Dec 14:56
da3f75d
Compare
Choose a tag to compare
Pre-release
  • Use *validation.Context in validation message placeholders. The validation.Placeholder signatures becomes func(fieldName string, language string, ctx *validation.Context) string. This is a breaking change.
  • Added Extra (map[string]interface{}) to *validation.Context. This allows placeholders to use additional information given by the validator function.
  • Added validation.StructList. This acts as a better alternative syntax for validation. The previous alternative syntax (*validation.Rules) should not be used for validation rules definition anymore but still works.

Pre-release v4.0.0-rc2

23 Nov 10:21
ca27a9c
Compare
Choose a tag to compare
Pre-release
  • Refactored the helper package and split it into several focused packages.
    • helper/filesystem moved to util/fsutil
    • helper/walk moved to util/walk
    • New package util/httputil
      • Contains ParseMultiValuesHeader() and HeaderValue
    • New package util/reflectutil
      • Contains Only()
    • New package util/sliceutil
      • Contains IndexOf(), IndexOfStr(), Contains(), ContainsStr() and Equal() (previously named SliceEqual())
    • New pacakge util/sqlutil
      • Contains EscapeLike()
    • New package util/typeutil
      • Contains Map, ToFloat64(), ToString()

Motivation: The helper packaged started to become more and more bloated with functions for things unrelated to each other. To make this part of the code more idiomatic and expressive, the decision to split the package in several parts and re-think the naming was taken.

  • The required rules now allows empty strings.
  • Removed model:"hide" because it was redundant with json:"-".
  • Added goyave.ProxyBaseURL() and server.proxy configuration entries.
  • Added global middleware. Global middleware are executed on all requests, including requests that don't match any route or that result in "Method Not Allowed". This allows for better logging, rate limiting, and more, while keeping the already existing tools.

Pre-release v4.0.0-rc1

26 Aug 13:45
e135be2
Compare
Choose a tag to compare
Pre-release
  • Only the last two major versions of Go will be supported, starting with this release.

Motivation: Supporting only the last two minor versions of the language follows Google's policy and allows for development of new modern features. It lets the framework be updated without it being considered a breaking change, and encourages to not use outdated versions of the language while newer ones contain security fixes.

  • Validation changes
    • Added validation rules before_now and after_now.
    • Added validation RuleSet and Rules composition for re-usability of redundant validated objects.
    • Changed signature of validation.RuleFunc to func(*validation.Context) bool. validation.Context provides more information and a cleaner and more flexible API.
      • Note: Converting rules now modify context.Value instead of directly modifying the input data.
    • Improved n-dimensional array validation with a new syntax.
      • The chevron-based syntax disappears in favor of a new more idiomatic syntax based on the name of the field, for example array[] will validate all the elements of the array array.
      • This new syntax allows for the validation of objects inside arrays.
    • Improved tree-like validation error messages structure, identifying precisely each element based on the expected structure. This structure also identifies each array element precisely with its index.
    • Removed the confirmed validation rule. Use same:path.to.field instead.
    • If a field is missing and not required, child fields are now skipped. This prevents required rules to not pass if the parent is not required and missing.

Motivation: Although the validation package has seen some major improvements in v3, it was still far from perfect and was really lacking some important capabilities, such as the validation of objects in arrays. The array validation syntax was confusing, hard to read, and incompatible with the new syntax that was needed for object validation in arrays. We now have a more readable syntax, offering better capabilities. Because of how differently the validator works internally, we also had the opportunity to rework the error messages output, which now offers an impressive degree of precision. Precision in error messages gives a real edge over competing validation libraries.

  • Added helper/walk package to navigate complex data structure of unknown type (map[string]interface{}). This is used by the validator.
  • Migrated from dgrijalva/jwt-go library to the maintained golang-jwt/jwt.
  • Added ability to set default language strings from code using lang.SetDefaultLine(), lang.SetDefaultValidationRule() and lang.SetDefaultFieldName().
  • JWT: now uses standard sub instead of userid by default.
  • Reduced the amount of reflection in auth.FindColums.
  • Added support for promoted pointer of struct in auth.FindColumns and helper.Only.
  • database.Paginator improvements
    • Now exports its DB field so it can be re-assigned with new clauses.
    • Now exports its UpdatePageInfo() method so it can be called manually before the real query.
    • Now uses a Gorm session for page info query to prevent weird queries in some specific scenarios.
    • Fields names are now in camel case when json marshalling a Paginator.
  • Removed the DisallowNonValidatedFields middleware as it would be too expensive and complex to properly implement it with the new validation system.
  • Removed the unused name parameter in request.Cookie(). Thanks to @agbaraka for the contribution!
  • Fixed duplicate error message when a request accessor panicked.

Release v3.11.0

17 Aug 15:21
70ca78e
Compare
Choose a tag to compare
  • Exported validation.Rules.Check() and validation.Field.Check().
  • Added validation rule exists.
  • Changed default invalid credentials "en-US" language entry to "Invalid credentials.".
  • Added auth.Unauthorizer.

Release v3.10.1

03 Jul 19:52
eec4d6c
Compare
Choose a tag to compare
  • Fixed native middleware don't replace http.Request and always used the initial one.
  • Fixed CORS options not working on subrouters. The main router's ones were always used.
  • Fixed route groups at root level don't match routes with / prefix.

Release v3.10.0

28 Jun 13:15
26939ef
Compare
Choose a tag to compare
  • Added Gorm settings to configuration file. Thanks to Zao SOULA for the contribution!

Release v3.9.1

28 May 14:23
7cd9f01
Compare
Choose a tag to compare

Fixed a crash when using the nullable rule.

Release v3.9.0

28 May 14:02
eff929d
Compare
Choose a tag to compare
  • Fixed random inconsistencies in validation results when using rules comparing value to other fields.
  • Added RuleDefinition.ComparesFields to specify a rule can compare the field under validation with another field. Custom rules that do so should update their definition to avoid previously mentioned inconsistencies.
  • Fixed a bug causing the shutdown hook listening to SIGINT and SIGTERM to clear itself at server startup.
  • Fixed a bug causing fields inside objects to not be converted by type rules and leaving junk into the input data.
  • Handle dot-separated path for comparison validation rules.