Liking cljdoc? Tell your friends :D

wagoe.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

admin-change-refusalclj

(admin-change-refusal actor-platform-admin? before after)

A :forbidden error when after sets or clears before's :admin and the actor is not a platform admin, else nil.

A :forbidden error when `after` sets or clears `before`'s :admin and the
actor is not a platform admin, else nil.
sourceraw docstring

admin-changes?clj

(admin-changes? before after)

Whether after sets or clears before's :admin. A key after leaves out is kept; before is nil for a new user.

Whether `after` sets or clears `before`'s :admin. A key `after` leaves out
is kept; `before` is nil for a new user.
sourceraw docstring

admin-removal-refusalclj

(admin-removal-refusal actor-id target other-active-admins)

Why taking admin rights from target is refused, or nil: no admin removes their own, and the last active admin keeps theirs (BOU-665).

Why taking admin rights from `target` is refused, or nil: no admin removes
their own, and the last active admin keeps theirs (BOU-665).
sourceraw 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

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

deactivates?clj

(deactivates? before after)

Whether after deactivates the active user before.

Whether `after` deactivates the active user `before`.
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

normalize-roleclj

(normalize-role user-data)

user-data with the role it is stored with: :admin or none. :user meant none and is read so until 2.0.

`user-data` with the role it is stored with: `:admin` or none. `:user`
meant none and is read so until 2.0.
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)

user-entity stamped with current-time as :updated-at. Deactivating sets :active only; :deleted-at is for deletes, so a deactivated user stays listed and can be reactivated (BOU-681).

`user-entity` stamped with `current-time` as :updated-at. Deactivating
sets :active only; :deleted-at is for deletes, so a deactivated user stays
listed and can be reactivated (BOU-681).
sourceraw docstring

refusal?clj

(refusal? e)

Whether exception e is a write refused by a rule, such as the guard above: a :conflict, shown to the user rather than raised.

Whether exception `e` is a write refused by a rule, such as the guard
above: a :conflict, shown to the user rather than raised.
sourceraw docstring

removes-admin?clj

(removes-admin? before after)

Whether after takes an active admin's rights away from before: a demotion, a deactivation, or, with after nil, a delete. A key after leaves out keeps its value.

Whether `after` takes an active admin's rights away from `before`: a
demotion, a deactivation, or, with `after` nil, a delete. A key `after`
leaves out keeps its value.
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-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

without-credentialsclj

(without-credentials user)

user with its secrets removed.

`user` with its secrets removed.
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