Skip to content

Commit

Permalink
feat(entity): create user model
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed Feb 26, 2023
1 parent baa3894 commit a510a0f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/kotlin/entity/user/User.kt
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!")
}
}
}
21 changes: 21 additions & 0 deletions src/main/kotlin/entity/user/UserData.kt
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
}

0 comments on commit a510a0f

Please sign in to comment.