-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
110 lines (110 loc) · 3.49 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Package is provides a comprehensive set of validation functions for data
// formats commonly used in web applications, financial systems, and general
// software development.
//
// # Overview
//
// The package offers validation functions for various data types and formats:
//
// - Identity and Access: email addresses, nicknames, variable names;
// - Financial: bank card numbers, IBAN accounts;
// - Geographic: latitude/longitude coordinates;
// - Network: IPv4/IPv6 addresses;
// - Telecommunications: phone numbers in E.164 format;
// - String Types: alphanumeric, numeric, hexadecimal, binary;
// - Numbers: even/odd, positive/negative, natural numbers;
// - Encodings: Base64, Base64URL, JWT tokens;
// - Data formats: MD5 hashes.
//
// # Design Philosophy
//
// The package follows several key principles:
//
// - No data cleaning - functions validate data as-is without modification;
// - Zero dependencies - minimal external dependencies;
// - Type safety - extensive use of Go generics where appropriate;
// - Performance - optimized for speed and minimal memory allocation.
//
// # Usage
//
// Most functions follow a simple pattern returning a boolean
// indicating validity:
//
// if is.Email("[email protected]") {
// // Valid email address
// }
//
// if is.BankCard("4111111111111111") {
// // Valid bank card number
// }
//
// Some functions support additional validation modes:
//
// // Strict mode validation
// if is.Nickname("user123", true) {
// // Valid nickname in strict mode
// }
//
// # Data Cleaning
//
// This package does not perform data cleaning. If input needs cleaning,
// use appropriate tools beforehand. For example, with the companion 'g' package:
//
// // Clean IBAN before validation
// raw := "GB82 WEST 1234 5698 7654 32" // contains spaces
// iban := g.Weed(raw, g.Whitespaces) // remove spaces
// if is.IBAN(iban) {
// // Valid IBAN
// }
//
// # Common Validation Patterns
//
// Account Validation:
//
// is.Email("[email protected]") // Email address
// is.Nickname("user123") // Username
// is.VariableName("myVar") // Programming variable name
//
// Financial Validation:
//
// is.BankCard("4111111111111111") // Bank card number
// is.IBAN("DE89370400440532013000") // IBAN account number
//
// Geographic Validation:
//
// is.Latitude(45.423) // Latitude coordinate
// is.Longitude(-75.935) // Longitude coordinate
//
// Network Address Validation:
//
// is.IPv4("192.168.0.1") // IPv4 address
// is.IPv6("2001:db8::1") // IPv6 address
//
// Phone Number Validation:
//
// is.E164("+1234567890") // E.164 format
// is.Phone("+1 (234) 567-890") // General phone format
//
// String Type Validation:
//
// is.Alpha("ABC") // Alphabetic characters
// is.Digit("123") // Numeric digits
// is.Alnum("ABC123") // Alphanumeric characters
// is.HexColor("#FF5733") // Hexadecimal color
//
// Number Validation:
//
// is.Even(4) // Even number
// is.Odd(3) // Odd number
// is.Natural(5) // Natural number
// is.Positive(1.5) // Positive number
//
// Format Validation:
//
// is.Base64("SGVsbG8=") // Base64 encoding
// is.MD5("d41d8cd98f00b204...") // MD5 hash
// is.JWT("eyJhbGciOiJIUzI...") // JWT token
//
// For more detailed information about specific validation functions,
// see their respective documentation.
package is