@@ -346,6 +346,7 @@ const (
346346 uuidV3 = 3
347347 uuidV4 = 4
348348 uuidV5 = 5
349+ uuidV7 = 7
349350)
350351
351352// IsUUID3 returns true is the string matches a UUID v3, upper case is allowed
@@ -366,6 +367,12 @@ func IsUUID5(str string) bool {
366367 return err == nil && id .Version () == uuid .Version (uuidV5 )
367368}
368369
370+ // IsUUID7 returns true is the string matches a UUID v7, upper case is allowed
371+ func IsUUID7 (str string ) bool {
372+ id , err := uuid .Parse (str )
373+ return err == nil && id .Version () == uuid .Version (uuidV7 )
374+ }
375+
369376// IsEmail validates an email address.
370377func IsEmail (str string ) bool {
371378 addr , e := mail .ParseAddress (str )
@@ -394,6 +401,7 @@ func init() {
394401 // - uuid3
395402 // - uuid4
396403 // - uuid5
404+ // - uuid7
397405 u := URI ("" )
398406 Default .Add ("uri" , & u , isRequestURI )
399407
@@ -427,6 +435,9 @@ func init() {
427435 uid5 := UUID5 ("" )
428436 Default .Add ("uuid5" , & uid5 , IsUUID5 )
429437
438+ uid7 := UUID7 ("" )
439+ Default .Add ("uuid7" , & uid7 , IsUUID7 )
440+
430441 isbn := ISBN ("" )
431442 Default .Add ("isbn" , & isbn , func (str string ) bool { return isISBN10 (str ) || isISBN13 (str ) })
432443
@@ -1320,6 +1331,78 @@ func (u *UUID5) DeepCopy() *UUID5 {
13201331 return out
13211332}
13221333
1334+ // UUID7 represents a uuid7 string format
1335+ //
1336+ // swagger:strfmt uuid7
1337+ type UUID7 string
1338+
1339+ // MarshalText turns this instance into text
1340+ func (u UUID7 ) MarshalText () ([]byte , error ) {
1341+ return []byte (string (u )), nil
1342+ }
1343+
1344+ // UnmarshalText hydrates this instance from text
1345+ func (u * UUID7 ) UnmarshalText (data []byte ) error { // validation is performed later on
1346+ * u = UUID7 (string (data ))
1347+ return nil
1348+ }
1349+
1350+ // Scan read a value from a database driver
1351+ func (u * UUID7 ) Scan (raw any ) error {
1352+ switch v := raw .(type ) {
1353+ case []byte :
1354+ * u = UUID7 (string (v ))
1355+ case string :
1356+ * u = UUID7 (v )
1357+ default :
1358+ return fmt .Errorf ("cannot sql.Scan() strfmt.UUID7 from: %#v: %w" , v , ErrFormat )
1359+ }
1360+
1361+ return nil
1362+ }
1363+
1364+ // Value converts a value to a database driver value
1365+ func (u UUID7 ) Value () (driver.Value , error ) {
1366+ return driver .Value (string (u )), nil
1367+ }
1368+
1369+ func (u UUID7 ) String () string {
1370+ return string (u )
1371+ }
1372+
1373+ // MarshalJSON returns the UUID as JSON
1374+ func (u UUID7 ) MarshalJSON () ([]byte , error ) {
1375+ return json .Marshal (string (u ))
1376+ }
1377+
1378+ // UnmarshalJSON sets the UUID from JSON
1379+ func (u * UUID7 ) UnmarshalJSON (data []byte ) error {
1380+ if string (data ) == jsonNull {
1381+ return nil
1382+ }
1383+ var ustr string
1384+ if err := json .Unmarshal (data , & ustr ); err != nil {
1385+ return err
1386+ }
1387+ * u = UUID7 (ustr )
1388+ return nil
1389+ }
1390+
1391+ // DeepCopyInto copies the receiver and writes its value into out.
1392+ func (u * UUID7 ) DeepCopyInto (out * UUID7 ) {
1393+ * out = * u
1394+ }
1395+
1396+ // DeepCopy copies the receiver into a new UUID7.
1397+ func (u * UUID7 ) DeepCopy () * UUID7 {
1398+ if u == nil {
1399+ return nil
1400+ }
1401+ out := new (UUID7 )
1402+ u .DeepCopyInto (out )
1403+ return out
1404+ }
1405+
13231406// ISBN represents an isbn string format
13241407//
13251408// swagger:strfmt isbn
0 commit comments