Liking cljdoc? Tell your friends :D

boundary.user.core.user

Functional Core - Pure user business logic.

This namespace contains ONLY pure functions with no side effects:

  • No I/O operations (no database calls, no logging, no HTTP)
  • No external dependencies (time, random generation, etc.)
  • Deterministic behavior (same input always produces same output)
  • Immutable data structures only

All business rules and domain logic for users belong here. The shell layer orchestrates I/O and calls these pure functions.

Functional Core - Pure user business logic.

This namespace contains ONLY pure functions with no side effects:
- No I/O operations (no database calls, no logging, no HTTP)
- No external dependencies (time, random generation, etc.)
- Deterministic behavior (same input always produces same output)
- Immutable data structures only

All business rules and domain logic for users belong here.
The shell layer orchestrates I/O and calls these pure functions.
raw docstring

analyze-user-activityclj

(analyze-user-activity user activity-events analysis-period-days now)

Pure function: Analyze user activity patterns from activity data.

Args: user: User entity activity-events: Vector of activity event maps analysis-period-days: Number of days to analyze now: Instant cutoff for recent activity filtering

Returns: Map with activity analysis results

Pure - data analysis based on input events.

Pure function: Analyze user activity patterns from activity data.

Args:
  user: User entity
  activity-events: Vector of activity event maps
  analysis-period-days: Number of days to analyze
  now: Instant cutoff for recent activity filtering

Returns:
  Map with activity analysis results

Pure - data analysis based on input events.
sourceraw docstring

apply-user-filtersclj

(apply-user-filters users filters)

Pure function: Apply business filters to user list.

Args: users: Vector of user entities filters: Map of filter criteria {:role :admin, :active true, etc.}

Returns: Filtered vector of users

Pure - data filtering based on criteria.

Pure function: Apply business filters to user list.

Args:
  users: Vector of user entities
  filters: Map of filter criteria {:role :admin, :active true, etc.}

Returns:
  Filtered vector of users

Pure - data filtering based on criteria.
sourceraw docstring

calculate-user-changesclj

(calculate-user-changes current-user updated-user)

Pure function: Calculate what fields are being changed.

Args: current-user: Current user entity from database updated-user: Updated user data

Returns: Map with changes: {:field {:from old-value :to new-value}}

Pure - data comparison only.

Pure function: Calculate what fields are being changed.

Args:
  current-user: Current user entity from database
  updated-user: Updated user data

Returns:
  Map with changes: {:field {:from old-value :to new-value}}

Pure - data comparison only.
sourceraw docstring

calculate-user-membership-tierclj

(calculate-user-membership-tier user current-date)

Pure function: Calculate membership tier based on user data.

Args: user: User entity with join date and activity data current-date: Current date for calculation

Returns: Keyword tier (:bronze :silver :gold :platinum)

Pure - business calculation based on input data only.

Pure function: Calculate membership tier based on user data.

Args:
  user: User entity with join date and activity data
  current-date: Current date for calculation

Returns:
  Keyword tier (:bronze :silver :gold :platinum)

Pure - business calculation based on input data only.
sourceraw docstring

calculate-user-permissionsclj

(calculate-user-permissions user)

Pure function: Calculate user permissions based on role.

Args: user: User entity with role information

Returns: Set of permission keywords

Pure - permission calculation based on input data.

Pure function: Calculate user permissions based on role.

Args:
  user: User entity with role information

Returns:
  Set of permission keywords

Pure - permission calculation based on input data.
sourceraw docstring

can-delete-user?clj

(can-delete-user? user)

Pure function: Determine if user can be deleted.

Args: user: User entity to check

Returns: {:allowed? true} or {:allowed? false :reason keyword}

Pure - business rule checking only.

Pure function: Determine if user can be deleted.

Args:
  user: User entity to check

Returns:
  {:allowed? true} or
  {:allowed? false :reason keyword}

Pure - business rule checking only.
sourceraw docstring

can-hard-delete-user?clj

(can-hard-delete-user? user)

Pure function: Determine if user can be hard deleted.

Args: user: User entity to check

Returns: {:allowed? true} or {:allowed? false :reason keyword}

Pure - business rule checking only.

Pure function: Determine if user can be hard deleted.

Args:
  user: User entity to check

Returns:
  {:allowed? true} or
  {:allowed? false :reason keyword}

Pure - business rule checking only.
sourceraw docstring

check-duplicate-user-decisionclj

(check-duplicate-user-decision user-data existing-user)

Pure function: Determine if user creation should proceed based on existing user lookup.

Args: user-data: User data to create existing-user: Result of looking up user by email (or nil if not found)

Returns: {:decision :proceed} or {:decision :reject :reason :duplicate-email :email string}

Pure - no database calls, just decision logic based on inputs.

Pure function: Determine if user creation should proceed based on existing user lookup.

Args:
  user-data: User data to create
  existing-user: Result of looking up user by email (or nil if not found)

Returns:
  {:decision :proceed} or
  {:decision :reject :reason :duplicate-email :email string}

Pure - no database calls, just decision logic based on inputs.
sourceraw docstring

check-user-exists-for-update-decisionclj

(check-user-exists-for-update-decision user-entity existing-user)

Pure function: Determine if user update should proceed based on existing user.

Args: user-entity: User entity to update existing-user: Current user from database (or nil if not found)

Returns: {:decision :proceed} or {:decision :reject :reason :user-not-found :user-id uuid}

Pure - decision logic only, no database operations.

Pure function: Determine if user update should proceed based on existing user.

Args:
  user-entity: User entity to update
  existing-user: Current user from database (or nil if not found)

Returns:
  {:decision :proceed} or
  {:decision :reject :reason :user-not-found :user-id uuid}

Pure - decision logic only, no database operations.
sourceraw docstring

filter-active-usersclj

(filter-active-users users)

Pure function: Filter list of users to only include active ones.

Args: users: Vector of user entities

Returns: Vector of active users (deleted-at is nil)

Pure - data transformation only.

Pure function: Filter list of users to only include active ones.

Args:
  users: Vector of user entities

Returns:
  Vector of active users (deleted-at is nil)

Pure - data transformation only.
sourceraw docstring

prepare-user-for-creationclj

(prepare-user-for-creation user-data current-time user-id)

Pure function: Prepare user data for creation with business defaults.

Args: user-data: Validated user creation request current-time: Instant representing current time user-id: UUID for the new user

Returns: Complete user entity ready for persistence

Pure - takes time and ID as parameters instead of generating them.

Pure function: Prepare user data for creation with business defaults.

Args:
  user-data: Validated user creation request
  current-time: Instant representing current time
  user-id: UUID for the new user

Returns:
  Complete user entity ready for persistence

Pure - takes time and ID as parameters instead of generating them.
sourceraw docstring

prepare-user-for-soft-deletionclj

(prepare-user-for-soft-deletion user current-time)

Pure function: Prepare user for soft deletion.

Args: user: Current user entity current-time: Current time instant

Returns: User entity marked as deleted

Pure - data transformation only.

Pure function: Prepare user for soft deletion.

Args:
  user: Current user entity
  current-time: Current time instant

Returns:
  User entity marked as deleted

Pure - data transformation only.
sourceraw docstring

prepare-user-for-updateclj

(prepare-user-for-update user-entity current-time)

Pure function: Prepare user entity for update with business rules.

Handles the active field by setting deleted-at:

  • When active is false (deactivated): sets deleted-at to current-time
  • When active is true (activated): sets deleted-at to nil

Args: user-entity: User entity to update current-time: Instant representing current time

Returns: User entity prepared for update with updated timestamp and deleted-at

Pure - takes time as parameter instead of generating it.

Pure function: Prepare user entity for update with business rules.

Handles the active field by setting deleted-at:
- When active is false (deactivated): sets deleted-at to current-time
- When active is true (activated): sets deleted-at to nil

Args:
  user-entity: User entity to update
  current-time: Instant representing current time
  
Returns:
  User entity prepared for update with updated timestamp and deleted-at
  
Pure - takes time as parameter instead of generating it.
sourceraw docstring

should-require-password-reset?clj

(should-require-password-reset? user current-time password-policy)

Pure function: Determine if user should be required to reset password.

Args: user: User entity with password metadata current-time: Current time instant password-policy: Password policy configuration

Returns: Boolean indicating if password reset is required

Pure - business rule evaluation based on policy and user data.

Pure function: Determine if user should be required to reset password.

Args:
  user: User entity with password metadata
  current-time: Current time instant
  password-policy: Password policy configuration

Returns:
  Boolean indicating if password reset is required

Pure - business rule evaluation based on policy and user data.
sourceraw docstring

sort-users-by-criteriaclj

(sort-users-by-criteria users sort-by sort-direction)

Pure function: Sort users by specified criteria.

Args: users: Vector of user entities sort-by: Keyword field to sort by (:created-at, :email, :role) sort-direction: :asc or :desc

Returns: Sorted vector of users

Pure - data sorting only.

Pure function: Sort users by specified criteria.

Args:
  users: Vector of user entities
  sort-by: Keyword field to sort by (:created-at, :email, :role)
  sort-direction: :asc or :desc

Returns:
  Sorted vector of users

Pure - data sorting only.
sourceraw docstring

validate-email-domainclj

(validate-email-domain email allowed-domains)

Pure function: Validate email domain against allowed domains.

Args: email: Email address string allowed-domains: Set of allowed domain strings

Returns: {:valid? true} or {:valid? false :reason string}

Pure - string validation against domain allowlist.

Pure function: Validate email domain against allowed domains.

Args:
  email: Email address string
  allowed-domains: Set of allowed domain strings

Returns:
  {:valid? true} or {:valid? false :reason string}

Pure - string validation against domain allowlist.
sourceraw docstring

validate-user-business-rulesclj

(validate-user-business-rules _updated-user changes)

Pure function: Validate business rules for user changes.

Args: updated-user: Updated user entity changes: Map of changes (from calculate-user-changes)

Returns: {:valid? true} or {:valid? false :errors error-details}

Pure - business rule validation only.

Pure function: Validate business rules for user changes.

Args:
  updated-user: Updated user entity
  changes: Map of changes (from calculate-user-changes)

Returns:
  {:valid? true} or
  {:valid? false :errors error-details}

Pure - business rule validation only.
sourceraw docstring

validate-user-creation-requestclj

(validate-user-creation-request user-data validation-config)

Pure function: Validate user creation request against comprehensive business rules.

Args: user-data: User creation request data validation-config: Map containing validation policies and settings {:email-domain-allowlist #{"example.com" "acme.com"} :password-policy {:min-length 8 :require-special-chars? true :require-numbers? true} :name-restrictions {:min-length 2 :max-length 100 :allowed-chars-regex #"[a-zA-Z\s-'.]"}}

Returns: {:valid? true :data processed-data} or {:valid? false :errors [{:field :email :code :invalid-domain :message "..."}]}

Pure - no side effects, comprehensive domain validation.

Pure function: Validate user creation request against comprehensive business rules.

Args:
  user-data: User creation request data
  validation-config: Map containing validation policies and settings
    {:email-domain-allowlist #{"example.com" "acme.com"}
     :password-policy {:min-length 8 :require-special-chars? true :require-numbers? true}
     :name-restrictions {:min-length 2 :max-length 100 :allowed-chars-regex #"[a-zA-Z\s-'.]"}}

Returns:
  {:valid? true :data processed-data} or
  {:valid? false :errors [{:field :email :code :invalid-domain :message "..."}]}

Pure - no side effects, comprehensive domain validation.
sourceraw docstring

validate-user-role-transitionclj

(validate-user-role-transition current-role new-role requesting-user-role)

Pure function: Validate if role transition is allowed by business rules.

Args: current-role: Current user role keyword new-role: Proposed new role keyword requesting-user-role: Role of user making the request

Returns: {:valid? true} or {:valid? false :reason string}

Pure - business rule evaluation for role transitions.

Pure function: Validate if role transition is allowed by business rules.

Args:
  current-role: Current user role keyword
  new-role: Proposed new role keyword
  requesting-user-role: Role of user making the request

Returns:
  {:valid? true} or {:valid? false :reason string}

Pure - business rule evaluation for role transitions.
sourceraw docstring

validate-user-update-requestclj

(validate-user-update-request user-entity)

Pure function: Validate user update request against business rules.

Args: user-entity: Complete user entity for update

Returns: {:valid? true :data user-entity} or {:valid? false :errors validation-errors}

Pure - schema validation only, no external dependencies.

Pure function: Validate user update request against business rules.

Args:
  user-entity: Complete user entity for update

Returns:
  {:valid? true :data user-entity} or
  {:valid? false :errors validation-errors}

Pure - schema validation only, no external dependencies.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close