-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
246 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2024 Anass Bouassaba. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file LICENSE in the root of this repository. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the GNU Affero General Public License v3.0 only, included in the file | ||
// AGPL-3.0-only in the root of this repository. | ||
|
||
import Foundation | ||
|
||
extension String { | ||
func hasMinLength(_ count: Int) -> Bool { | ||
self.count >= count | ||
} | ||
|
||
func hasMinLowerCase(_ count: Int) -> Bool { | ||
self.filter { $0.isLowercase }.count >= count | ||
} | ||
|
||
func hasMinUpperCase(_ count: Int) -> Bool { | ||
self.filter { $0.isUppercase }.count >= count | ||
} | ||
|
||
func hasMinNumbers(_ count: Int) -> Bool { | ||
self.filter { $0.isNumber }.count >= count | ||
} | ||
|
||
func hasMinSymbols(_ count: Int) -> Bool { | ||
let symbolsSet = CharacterSet.alphanumerics.union(.whitespaces).inverted | ||
let symbolsCount = self.unicodeScalars.filter { symbolsSet.contains($0) }.count | ||
return symbolsCount >= count | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters