Skip to content

Commit

Permalink
openapi3: remove email string format (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
zekth committed Dec 30, 2022
1 parent 46e0df8 commit 92d47ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func arrayUniqueItemsChecker(items []interface{}) bool {

## Sub-v0 breaking API changes

### v0.113.0
* The string format `email` has been removed by default. To use it please call `openapi3.DefineStringFormat("email", openapi3.FormatOfStringForEmail)`.

### v0.112.0
* `(openapi3.ValidationOptions).ExamplesValidationDisabled` has been unexported.
* `(openapi3.ValidationOptions).SchemaFormatValidationEnabled` has been unexported.
Expand Down
8 changes: 4 additions & 4 deletions openapi3/schema_formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
const (
// FormatOfStringForUUIDOfRFC4122 is an optional predefined format for UUID v1-v5 as specified by RFC4122
FormatOfStringForUUIDOfRFC4122 = `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$`

// FormatOfStringForEmail pattern catches only some suspiciously wrong-looking email addresses.
// Use DefineStringFormat(...) if you need something stricter.
FormatOfStringForEmail = `^[^@]+@[^@<>",\s]+$`
)

// FormatCallback performs custom checks on exotic formats
Expand Down Expand Up @@ -79,10 +83,6 @@ func validateIPv6(ip string) error {
}

func init() {
// This pattern catches only some suspiciously wrong-looking email addresses.
// Use DefineStringFormat(...) if you need something stricter.
DefineStringFormat("email", `^[^@]+@[^@<>",\s]+$`)

// Base64
// The pattern supports base64 and b./ase64url. Padding ('=') is supported.
DefineStringFormat("byte", `(^$|^[a-zA-Z0-9+/\-_]*=*$)`)
Expand Down

0 comments on commit 92d47ad

Please sign in to comment.