generated from SmartOperatingBlock/kotlin-template-project
-
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
1 parent
baa3894
commit a510a0f
Showing
2 changed files
with
53 additions
and
0 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,32 @@ | ||
/* | ||
* Copyright (c) 2023. Smart Operating Block | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
package entity.user | ||
|
||
import entity.user.UserData.PASSWORD_MAX_LENGTH | ||
import entity.user.UserData.PASSWORD_MIN_LENGTH | ||
|
||
/** The user of the Smart Operating block System. */ | ||
data class User( | ||
|
||
/** The identifier of the [User]. */ | ||
val userId: String, | ||
|
||
/** The [password] of the [User]. */ | ||
val password: String | ||
) { | ||
init { | ||
require(userId.isNotEmpty()) { | ||
throw IllegalArgumentException("Invalid userId!") | ||
} | ||
|
||
require(password.length in PASSWORD_MIN_LENGTH..PASSWORD_MAX_LENGTH) { | ||
throw IllegalArgumentException("Invalid user password!") | ||
} | ||
} | ||
} |
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,21 @@ | ||
/* | ||
* Copyright (c) 2023. Smart Operating Block | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
package entity.user | ||
|
||
/** | ||
* Module with some user data. | ||
*/ | ||
object UserData { | ||
|
||
/** The minimum length of the password. */ | ||
const val PASSWORD_MIN_LENGTH = 8 | ||
|
||
/** The maximum length of the password. */ | ||
const val PASSWORD_MAX_LENGTH = 20 | ||
} |