Liking cljdoc? Tell your friends :D

io.randomseed.utils.identity

Random Utilities, user identity abstraction.

Random Utilities, user identity abstraction.
raw docstring

->dbcljmacro

(->db user-identity)
(->db identity-type user-identity)

For the given user identity user-identity and optional identity type identity-type tries to express the given identity's value in a database suitable format.

Uses to-db* multimethod to perform user-identity transformation on a basis of its identity type.

If the given identity is not a kind of io.randomseed.utils.Identity record, it will be converted to it first. If the given value cannot be used as valid identity, nil is returned.

If the identity-type is given, it should be a valid identity type. It instructs the function to treat the given identity as of this type during pre-conversion. If the identity is already an io.randomseed.utils.Identity record but its type is different, nil will be returned.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

If the identity-type is given as literal keyword, string or nil, then a specific conversion function will be obtained at compile-time.

If identity-type is an acceptable literal (or not given at all) and user-identity expression is a value for which the function io.randomseed.utils.proto.identity/literal? returns true then the conversion is done immediately, and its result replaces the macro call at compile-time.

However, if the immediate conversion result is nil, or it is not a value for which the function io.randomseed.utils.proto.identity/literal? returns true, an expression with call to to-db or to-db* will be generated as fallback to perform the conversion at run-time.

For the given user identity `user-identity` and optional identity type
`identity-type` tries to express the given identity's value in a database suitable
format.

Uses `to-db*` multimethod to perform `user-identity` transformation on a basis of
its identity type.

If the given identity is not a kind of `io.randomseed.utils.Identity` record, it will be
converted to it first. If the given value cannot be used as valid identity, `nil`
is returned.

If the `identity-type` is given, it should be a valid identity type. It instructs
the function to treat the given identity as of this type during pre-conversion. If
the identity is already an `io.randomseed.utils.Identity` record but its type is different,
`nil` will be returned.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

If the `identity-type` is given as literal keyword, string or `nil`, then a
specific conversion function will be obtained at compile-time.

If `identity-type` is an acceptable literal (or not given at all) and
`user-identity` expression is a value for which the function
`io.randomseed.utils.proto.identity/literal?` returns `true` then the conversion is done
immediately, and its result replaces the macro call at compile-time.

However, if the immediate conversion result is `nil`, or it is not a value for
which the function `io.randomseed.utils.proto.identity/literal?` returns `true`, an
expression with call to `to-db` or `to-db*` will be generated as fallback to
perform the conversion at run-time.
sourceraw docstring

->strcljmacro

(->str user-identity)
(->str identity-type user-identity)

For the given user identity user-identity and optional identity type identity-type tries to express the given identity's value as a string.

Uses to-str* multimethod to perform user-identity transformation on a basis of its identity type.

If the given identity is not a kind of io.randomseed.utils.Identity record, it will be converted to it first. If the given value cannot be used as valid identity, nil is returned.

If the identity-type is given, it should be a valid identity type. It instructs the function to treat the given identity as of this type during pre-conversion. If the identity is already an io.randomseed.utils.Identity record but its type is different, nil will be returned.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

If the identity-type is given as literal keyword, string or nil, then a specific conversion function will be obtained at compile-time.

If identity-type is an acceptable literal (or not given at all) and user-identity expression is a value for which the function io.randomseed.utils.proto.identity/literal? returns true then the conversion is done immediately, and its result replaces the macro call at compile-time.

However, if the immediate conversion result is nil, or it is not a value for which the function io.randomseed.utils.proto.identity/literal? returns true, an expression with call to to-str or to-str* will be generated as fallback to perform the conversion at run-time.

For the given user identity `user-identity` and optional identity type
`identity-type` tries to express the given identity's value as a string.

Uses `to-str*` multimethod to perform `user-identity` transformation on a basis of
its identity type.

If the given identity is not a kind of `io.randomseed.utils.Identity` record, it will be
converted to it first. If the given value cannot be used as valid identity, `nil`
is returned.

If the `identity-type` is given, it should be a valid identity type. It instructs
the function to treat the given identity as of this type during pre-conversion. If
the identity is already an `io.randomseed.utils.Identity` record but its type is different,
`nil` will be returned.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

If the `identity-type` is given as literal keyword, string or `nil`, then a
specific conversion function will be obtained at compile-time.

If `identity-type` is an acceptable literal (or not given at all) and
`user-identity` expression is a value for which the function
`io.randomseed.utils.proto.identity/literal?` returns `true` then the conversion is done
immediately, and its result replaces the macro call at compile-time.

However, if the immediate conversion result is `nil`, or it is not a value for
which the function `io.randomseed.utils.proto.identity/literal?` returns `true`, an
expression with call to `to-str` or `to-str*` will be generated as fallback to
perform the conversion at run-time.
sourceraw docstring

acceptable-typeclj

(acceptable-type user-identity acceptable-tag)
(acceptable-type user-identity identity-type acceptable-tag)

Returns a keyword describing identity type detected by analyzing the given user identity user-identity and optional identity type identity-type given explicitly (e.g. :phone for a phone number, :email for e-mail address, :id for numeric user ID, :uid for UUID).

If the type is not given, or if it is nil or false, analysis of the given identity will be performed.

The given identity type must always be valid (registered with io.randomseed.utils.proto.identity/add-type!) and the identity must not be nil nor false. If any of these happens, nil will be returned.

The acceptable-tag should be a tag type from which the given type is derived within the hierarchy io.randomseed.utils.proto.identity/type-hierarchy.

To add acceptable type(s) use io.randomseed.utils.proto.identity/add-acceptable-type.

Returns a keyword describing identity type detected by analyzing the given user
identity `user-identity` and optional identity type `identity-type` given
explicitly (e.g. `:phone` for a phone number, `:email` for e-mail address, `:id`
for numeric user ID, `:uid` for UUID).

If the type is not given, or if it is `nil` or `false`, analysis of the given
identity will be performed.

The given identity type must always be valid (registered with
`io.randomseed.utils.proto.identity/add-type!`) and the identity must not be `nil` nor
`false`. If any of these happens, `nil` will be returned.

The `acceptable-tag` should be a tag type from which the given type is derived
within the hierarchy `io.randomseed.utils.proto.identity/type-hierarchy`.

To add acceptable type(s) use `io.randomseed.utils.proto.identity/add-acceptable-type`.
sourceraw docstring

add-acceptable-type!clj

(add-acceptable-type! acceptable-tag t)
(add-acceptable-type! acceptable-tag t & more)

For the given parent tag acceptable-tag (which should be a qualified keyword) and an identity type t, creates a relation so that the identity type is a descendant of the given parent. It also ensures that the parent itself is a descendant of :io.randomseed.utils.identity/valid tag.

Additionally, it makes an extra parent for the given acceptable tag in io.randomseed.utils.proto.identity/type-hierarchy which is :io.randomseed.utils.proto.identity/group. This special value is a valid dispatch for the parser multimethod which uses parse-group to handle identity parsing with acceptable tag given explicitly as its identity type specification. If you don't want that, use io.randomseed.utils.proto.identity/add-acceptable-type! directly.

Useful when there is a need to accept a limited set of recognized identity types. Then the detection function can check whether an identity belongs to a parent.

Makes changes in the global identity type hierarchy io.randomseed.utils.identity.proto/type-hierarchy.

For the given parent tag `acceptable-tag` (which should be a qualified keyword) and
an identity type `t`, creates a relation so that the identity type is a descendant
of the given parent. It also ensures that the parent itself is a descendant of
`:io.randomseed.utils.identity/valid` tag.

Additionally, it makes an extra parent for the given acceptable tag in
`io.randomseed.utils.proto.identity/type-hierarchy` which is
`:io.randomseed.utils.proto.identity/group`. This special value is a valid dispatch for the
`parser` multimethod which uses `parse-group` to handle identity parsing with
acceptable tag given explicitly as its identity type specification. If you don't
want that, use `io.randomseed.utils.proto.identity/add-acceptable-type!` directly.

Useful when there is a need to accept a limited set of recognized identity
types. Then the detection function can check whether an identity belongs to a
parent.

Makes changes in the global identity type hierarchy
`io.randomseed.utils.identity.proto/type-hierarchy`.
sourceraw docstring

check-typeclj

(check-type id-type)
(check-type id-type acceptable-tag)

Returns a keyword for the given identity type identity-type if it is a valid identity. Otherwise it returns nil. To add acceptable type(s) use io.randomseed.utils.proto.identity/add-acceptable-type.

If acceptable parent tag acceptable-tag is given, it must be a parent of the given identity type tag.

Returns a keyword for the given identity type `identity-type` if it is a valid
identity. Otherwise it returns `nil`. To add acceptable type(s) use
`io.randomseed.utils.proto.identity/add-acceptable-type`.

If acceptable parent tag `acceptable-tag` is given, it must be a parent of the
given identity type tag.
sourceraw docstring

id-email-stringclj

(id-email-string v)
(id-email-string v t)

Returns true if the given string looks like an e-mail address. If identity type or acceptable type t is given, then it must be a parent or be equal to :email.

Returns `true` if the given string looks like an e-mail address. If identity type or
acceptable type `t` is given, then it must be a parent or be equal to `:email`.
sourceraw docstring

id-id-stringclj

(id-id-string v)
(id-id-string v t)

Returns true if the given string looks like a user ID. If identity type or acceptable type t is given, then it must be a parent or be equal to :id.

Returns `true` if the given string looks like a user ID. If identity type or
acceptable type `t` is given, then it must be a parent or be equal to `:id`.
sourceraw docstring

id-phone-stringclj

(id-phone-string v)
(id-phone-string v t)

Returns true if the given string looks like a phone number. If identity type or acceptable type t is given, then it must be a parent or be equal to :phone.

Returns `true` if the given string looks like a phone number. If identity type or
acceptable type `t` is given, then it must be a parent or be equal to `:phone`.
sourceraw docstring

id-uid-stringclj

(id-uid-string v)
(id-uid-string v t)

Returns true if the given string looks like a UID (UUID). If identity type or acceptable type t is given, then it must be a parent or be equal to :uid.

Returns `true` if the given string looks like a UID (UUID). If identity type or
acceptable type `t` is given, then it must be a parent or be equal to `:uid`.
sourceraw docstring

identity-map-keysclj

Commonly known map keys which may contain user identity.

Commonly known map keys which may contain user identity.
sourceraw docstring

identity-map-keys-by-typeclj

Commonly known map keys which may contain user identity grouped by identity types.

Commonly known map keys which may contain user identity grouped by identity types.
sourceraw docstring

ofclj

(of user-identity)
(of identity-type user-identity)
(of user-identity & user-identities)
(of identity-type user-identity & user-identities)

For the given user identity user-identity tries to parse the identity and return an io.randomseed.utils.Identity record object containing a detected identity type and identity value in a form it expresses it best. If the identity type cannot be established and it was not given, nil is returned.

Optional identity type identity-type (which must be a keyword) may be given as a first argument. It is used to pick the right parser (if parsing is needed) or to simply reject wrong identity type (if io.randomseed.utils.Identity record is given).

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

If there is a need to give list of keywords as user identities (including the first), and not to give any identity type, then first argument's value needs to be converted to a string, or of-value or of-type should be used as an alternative.

If multiple identities are given it will return a sequence of these identities parsed with parsing functions chosen for detected identity types. If an identity type is cannot be detected and/or is not valid, nil value will be inserted into the corresponding location of generated output sequence.

For the given user identity `user-identity` tries to parse the identity and return
an `io.randomseed.utils.Identity` record object containing a detected identity type and
identity value in a form it expresses it best. If the identity type cannot be
established and it was not given, `nil` is returned.

Optional identity type `identity-type` (which must be a keyword) may be given as a
first argument. It is used to pick the right parser (if parsing is needed) or to
simply reject wrong identity type (if `io.randomseed.utils.Identity` record is given).

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

If there is a need to give list of keywords as user identities (including the
first), and not to give any identity type, then first argument's value needs to be
converted to a string, or `of-value` or `of-type` should be used as an alternative.

If multiple identities are given it will return a sequence of these identities
parsed with parsing functions chosen for detected identity types. If an identity
type is cannot be detected and/or is not valid, `nil` value will be inserted into
the corresponding location of generated output sequence.
sourceraw docstring

of-emailclj

(of-email v)

Parses e-mail by doing basic checks and transforming it to an Identity object.

Parses e-mail by doing basic checks and transforming it to an Identity object.
sourceraw docstring

of-idclj

(of-id v)

Parses user ID by doing basic checks and transforming it to an Identity record.

Parses user ID by doing basic checks and transforming it to an Identity record.
sourceraw docstring

of-known-type?clj

(of-known-type? v)
(of-known-type? v acceptable-tag)

Returns true if the given value v is a user identity of the known type.

If the acceptable-tag is present then it should be a tag type from which the given type is derived within hierarchy io.randomseed.utils.proto.identity/type-hierarchy.

To add acceptable type(s) use io.randomseed.utils.proto.identity/add-acceptable-type.

Returns `true` if the given value `v` is a user identity of the known type.

If the `acceptable-tag` is present then it should be a tag type from which the
given type is derived within hierarchy `io.randomseed.utils.proto.identity/type-hierarchy`.

To add acceptable type(s) use `io.randomseed.utils.proto.identity/add-acceptable-type`.
sourceraw docstring

of-phoneclj

(of-phone v)

Tries to interpret v as a phone number and returns an Identity record.

Tries to interpret `v` as a phone number and returns an Identity record.
sourceraw docstring

of-seqclj

(of-seq user-identities)
(of-seq identity-type user-identities)

For the given user identities user-identities tries to parse each identity and return an io.randomseed.utils.Identity record containing a detected identity type and identity value in a form it expresses it best. If the given identity type was given as an optional identity-type argument, it will be assumed as the expected type for all input values.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

If an identity type was not given but it cannot be detected and/or is not valid, nil value will be inserted into the corresponding location of generated output sequence. Same with the given identity type which is not applicable to a particular value or invalid.

For the given user identities `user-identities` tries to parse each identity and
return an `io.randomseed.utils.Identity` record containing a detected identity type and
identity value in a form it expresses it best. If the given identity type was given
as an optional `identity-type` argument, it will be assumed as the expected type
for all input values.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

If an identity type was not given but it cannot be detected and/or is not valid,
`nil` value will be inserted into the corresponding location of generated output
sequence. Same with the given identity type which is not applicable to a particular
value or invalid.
sourceraw docstring

of-typeclj

(of-type identity-type user-identity)
(of-type identity-type user-identity & ids)

For the given user identity user-identity and identity type identity-type it tries to parse the identity and return an io.randomseed.utils.Identity record containing an identity type and identity value in a form it expresses it best. If the identity type is nil then nil is returned.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

If multiple identities are given it will return a sequence of these identities parsed with parsing functions chosen for the given identity type. If the identity type is not valid or the parsing cannot be applied for an input value, nil will be inserted into corresponding location of the output sequence.

For the given user identity `user-identity` and identity type `identity-type` it
tries to parse the identity and return an `io.randomseed.utils.Identity` record containing an
identity type and identity value in a form it expresses it best. If the identity
type is `nil` then `nil` is returned.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

If multiple identities are given it will return a sequence of these identities
parsed with parsing functions chosen for the given identity type. If the identity
type is not valid or the parsing cannot be applied for an input value, `nil` will
be inserted into corresponding location of the output sequence.
sourceraw docstring

of-uidclj

(of-uid v)

Tries to interpret v as a UUID and returns an Identity record.

Tries to interpret `v` as a UUID and returns an Identity record.
sourceraw docstring

of-valueclj

(of-value user-identity)
(of-value user-identity & ids)

For the given user identity user-identity tries to parse its value and returns it.

If identity-type is given and user-identity is a correct identity it will return the user identity if it is of the given type or its child.

If identity-type is given and user-identity is not a correct identity it will try to parse it. If parsing is successful it will return it only if it is of the given type or its child.

For the given user identity `user-identity` tries to parse its value and returns it.

If `identity-type` is given and `user-identity` is a correct identity it will return
the user identity if it is of the given type or its child.

If `identity-type` is given and `user-identity` is not a correct identity it will
try to parse it. If parsing is successful it will return it only if it is of the
given type or its child.
sourceraw docstring

opt-typeclj

(opt-type identity-type user-identity)
(opt-type identity-type user-identity & ids)

For the given user identity user-identity and identity type identity-type it tries to parse it (if possible) and returns io.randomseed.utils.Identity object only if it is of the given type or its child.

This function differs from of-type in that it will return nil if identity-type is nil or false.

For the given user identity `user-identity` and identity type `identity-type` it
tries to parse it (if possible) and returns `io.randomseed.utils.Identity` object only if it
is of the given type or its child.

This function differs from `of-type` in that it will return `nil` if
`identity-type` is nil or false.
sourceraw docstring

parseclj

(parse user-identity)
(parse identity-type user-identity)

Parses the given identity user-identity with optional identity-type predefined. Returns an identity record of type io.randomseed.utils.Identity. Memoized proxy for parsing strings and other non-native data.

Do not use it directly, use of or of-type instead.

Caution: The identity type must be a keyword (it will not be coerced).

Parses the given identity `user-identity` with optional `identity-type`
predefined. Returns an identity record of type `io.randomseed.utils.Identity`. Memoized proxy
for parsing strings and other non-native data.

Do not use it directly, use `of` or `of-type` instead.

Caution: The identity type must be a keyword (it will not be coerced).
sourceraw docstring

parse-groupclj

(parse-group acceptable-type user-identity)

Parses identity identity-type with acceptable-type tag which should be a parent tag grouping identity types (like :io.randomseed.utils.identity/any or another). Will use io.randomseed.utils.proto.identity/type passing a tag to it to limit the parsers tried and constrain the identity type to one that belongs to a parent tag in io.randomseed.utils.proto.identity/type-hierarchy. Hint: new parent tags can be registered with io.randomseed.utils.proto.identity/add-acceptable-type!.

This is internal function. Use of-type instead, which will choose the appropriate parser via multimethod and cache the results.

Parses identity `identity-type` with `acceptable-type` tag which should be a parent
tag grouping identity types (like `:io.randomseed.utils.identity/any` or another). Will use
`io.randomseed.utils.proto.identity/type` passing a tag to it to limit the parsers tried and
constrain the identity type to one that belongs to a parent tag in
`io.randomseed.utils.proto.identity/type-hierarchy`. Hint: new parent tags can be registered
with `io.randomseed.utils.proto.identity/add-acceptable-type!`.

This is internal function. Use `of-type` instead, which will choose the appropriate
parser via multimethod and cache the results.
sourceraw docstring

parse-mapclj

(parse-map m)
(parse-map identity-type m)

Tries to parse identity v by analyzing it based on its type and/or its structure.

In case of maps with :user/id, :user/uid, :user/email, :user/phone keys it will use corresponding values to parse it.

In case of an :identity/type key it will use its value as the identity type tag and will use it to parse :identity/value or :user/identity key's value.

In case of a :user/identity key and no :identity/type key it will try to parse the value as any of supported identities.

In case of all other map values it will return nil.

Tries to parse identity `v` by analyzing it based on its type and/or its structure.

In case of maps with `:user/id`, `:user/uid`, `:user/email`, `:user/phone` keys it
will use corresponding values to parse it.

In case of an `:identity/type` key it will use its value as the identity type tag
and will use it to parse `:identity/value` or `:user/identity` key's value.

In case of a `:user/identity` key and no `:identity/type` key it will try to parse
the value as any of supported identities.

In case of all other map values it will return `nil`.
sourceraw docstring

parse-singleclj

(parse-single user-identity)
(parse-single identity-type user-identity)

Parses identity user-identity by choosing the parser with parser multimethod on a basis of the given identity-type or a detected identity type (by getting it with io.randomseed.utils.proto.identity/type). Returns user identity object or nil.

This is internal function. Use of or of-type instead, which will cache the results.

Parses identity `user-identity` by choosing the parser with `parser` multimethod on
a basis of the given `identity-type` or a detected identity type (by getting it
with `io.randomseed.utils.proto.identity/type`). Returns user identity object or `nil`.

This is internal function. Use `of` or `of-type` instead, which will cache the
results.
sourceraw docstring

parsercljmultimethod

Takes an identity type expressed as keyword and returns a parser suitable for that identity type. The parser function takes 1 argument and converts the given value to identity record (of type io.randomseed.utils.Identity).

Caution: The identity type must be a keyword (it will not be coerced).

Takes an identity type expressed as keyword and returns a parser suitable for that
identity type. The parser function takes 1 argument and converts the given value to
identity record (of type `io.randomseed.utils.Identity`).

Caution: The identity type must be a keyword (it will not be coerced).
sourceraw docstring

preparse-emailclj

(preparse-email v)

Parses e-mail by doing basic checks and transforming it to a string.

Parses e-mail by doing basic checks and transforming it to a string.
sourceraw docstring

preparse-idclj

(preparse-id v)

Parses user ID by doing basic checks and transforming it to a long number.

Parses user ID by doing basic checks and transforming it to a long number.
sourceraw docstring

preparse-phoneclj

(preparse-phone v)

Tries to create an object representing phone number. Returns nil if the input cannot be parsed.

Tries to create an object representing phone number. Returns `nil` if the input
cannot be parsed.
sourceraw docstring

preparse-uidclj

(preparse-uid v)

Tries to create UUID. Returns nil if the input cannot be converted to it.

Tries to create UUID. Returns `nil` if the input cannot be converted to it.
sourceraw docstring

some-seqclj

(some-seq user-identities)
(some-seq identity-type user-identities)

Tries to coerce identities to io.randomseed.utils.Identity objects and filters out those who are not of the acceptable type (given by acceptable-tag, can be :io.randomseed.utils.identity/any to accept all types).

Then it tries to parse each of the identities given and returns a sequence of io.randomseed.utils.Identity objects. Returns nil if acceptable-tag is nil or if no identities are to be parsed or no identities have been parsed successfully.

Tries to coerce identities to `io.randomseed.utils.Identity` objects and filters out those who
are not of the acceptable type (given by `acceptable-tag`, can be `:io.randomseed.utils.identity/any`
to accept all types).

Then it tries to parse each of the identities given and returns a sequence of
`io.randomseed.utils.Identity` objects. Returns `nil` if `acceptable-tag` is `nil` or if
no identities are to be parsed or no identities have been parsed successfully.
sourceraw docstring

to-dbclj

(to-db user-identity)
(to-db identity-type user-identity)

For the given user identity user-identity tries to express the identity in a database-ready form. It uses a formatter function from io.randomseed.utils.proto.identity/type-formatters or passes the value unchanged.

Optional identity type identity-type is a type tag which can be used to check if the identity is of this type or its child.

If formatter is not found, it will return nil.

Built-ins:

For identity type :id it will return a number. For identity type :uid it will return a UUID. For identity type :email it will return a lowercase string. For identity type :phone it will return a string.

For the given user identity `user-identity` tries to express the identity in a
database-ready form. It uses a `formatter` function from
`io.randomseed.utils.proto.identity/type-formatters` or passes the value unchanged.

Optional identity type `identity-type` is a type tag which can be used to check if
the identity is of this type or its child.

If formatter is not found, it will return `nil`.

Built-ins:

For identity type `:id` it will return a number.
For identity type `:uid` it will return a UUID.
For identity type `:email` it will return a lowercase string.
For identity type `:phone` it will return a string.
sourceraw docstring

to-db*cljmultimethod

(to-db* user-identity)
(to-db* identity-type user-identity)

For the given user identity user-identity which must be of type io.randomseed.utils.Identity, tries to express the identity in a database suitable format.

If the given value cannot be used as valid identity, nil is returned.

If the identity-type is given, it must be a keyword and it should be a valid identity type. It instructs the function to treat the given identity as of this type.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

This is internal multimethod which does not perform conversions or checks. Use to-db or ->db instead.

For the given user identity `user-identity` which must be of type
`io.randomseed.utils.Identity`, tries to express the identity in a database suitable format.

If the given value cannot be used as valid identity, `nil` is returned.

If the `identity-type` is given, it must be a keyword and it should be a valid
identity type. It instructs the function to treat the given identity as of this
type.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

This is internal multimethod which does not perform conversions or checks. Use
`to-db` or `->db` instead.
sourceraw docstring

to-strclj

(to-str user-identity)
(to-str identity-type user-identity)

Takes a user identity user-identity and optional identity type identity-type, and converts it to a string.

If the given identity is not a kind of io.randomseed.utils.Identity record it will be converted to it first. If the given value cannot be used as valid identity, nil is returned.

If the identity-type is given, it should be a valid identity type. It instructs the function to treat the given identity as of this type.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

If the identity is an io.randomseed.utils.Identity record but its type is different, nil will be returned.

Takes a user identity `user-identity` and optional identity type `identity-type`,
and converts it to a string.

If the given identity is not a kind of `io.randomseed.utils.Identity` record it will be
converted to it first. If the given value cannot be used as valid identity, `nil`
is returned.

If the `identity-type` is given, it should be a valid identity type. It instructs
the function to treat the given identity as of this type.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

If the identity is an `io.randomseed.utils.Identity` record but its type is different, `nil`
will be returned.
sourceraw docstring

to-str*cljmultimethod

(to-str* user-identity)
(to-str* identity-type user-identity)

Takes a user identity user-identity expressed as Identity record, and converts it to a string.

If the identity-type is given, it should be a valid identity type expressed with a keyword. It instructs the function to treat the given identity as of this type. If the identity type is different than in the given object, nil is returned.

A value of identity-type may also be an acceptable type tag (registered with add-acceptable-type!) which groups identity types. In such case parsing and detection will be constrained to identity types being its descendants.

This is internal multimethod which does not perform conversions or checks. Use to-str function or ->str macro instead.

Takes a user identity `user-identity` expressed as `Identity` record, and converts
it to a string.

If the `identity-type` is given, it should be a valid identity type expressed with
a keyword. It instructs the function to treat the given identity as of this
type. If the identity type is different than in the given object, `nil` is
returned.

A value of `identity-type` may also be an acceptable type tag (registered with
`add-acceptable-type!`) which groups identity types. In such case parsing and
detection will be constrained to identity types being its descendants.

This is internal multimethod which does not perform conversions or checks. Use
`to-str` function or `->str` macro instead.
sourceraw docstring

typeclj

(type user-identity)
(type identity-type user-identity)

Returns a keyword describing identity type detected by analyzing the given user identity user-identity and optional identity type identity-type given explicitly (e.g. :phone for a phone number, :email for e-mail address, :id for numeric user ID, :uid for UUID). If the type is not given, analysis of the given identity will be performed.

Value of the given identity type identity-type must match the identity type, and not be nil nor false. If any of these happens, nil will be returned.

Returns a keyword describing identity type detected by analyzing the given user
identity `user-identity` and optional identity type `identity-type` given
explicitly (e.g. `:phone` for a phone number, `:email` for e-mail address, `:id`
for numeric user ID, `:uid` for UUID). If the type is not given, analysis of the
given identity will be performed.

Value of the given identity type `identity-type` must match the identity type, and
not be `nil` nor `false`. If any of these happens, `nil` will be returned.
sourceraw docstring

type-optclj

(type-opt user-identity)
(type-opt identity-type user-identity)

Returns a keyword describing identity type detected by analyzing the given user identity user-identity and optional identity type identity-type given explicitly (e.g. :phone for a phone number, :email for e-mail address, :id for numeric user ID, :uid for UUID).

If the type is not given or it is nil, analysis of the given identity will be performed.

Value of the given identity type identity-type must match the identity type. If it does not, nil will be returned.

Returns a keyword describing identity type detected by analyzing the given user
identity `user-identity` and optional identity type `identity-type` given
explicitly (e.g. `:phone` for a phone number, `:email` for e-mail address, `:id`
for numeric user ID, `:uid` for UUID).

If the type is not given or it is `nil`, analysis of the given identity will be
performed.

Value of the given identity type `identity-type` must match the identity type. If
it does not, `nil` will be returned.
sourceraw docstring

type?clj

(type? t)
(type? t acceptable-tag)

Returns true if the given identity type identifier t exists and is valid.

If acceptable-tag is given this function will in addition check if the given tag is a parent of the given type identifier or is :io.randomseed.utils.identity/any. To add acceptable type(s) use io.randomseed.utils.proto.identity/add-acceptable-type.

Returns `true` if the given identity type identifier `t` exists and is valid.

If `acceptable-tag` is given this function will in addition check if the given tag
is a parent of the given type identifier or is `:io.randomseed.utils.identity/any`. To add
acceptable type(s) use `io.randomseed.utils.proto.identity/add-acceptable-type`.
sourceraw docstring

unaccept-type!clj

(unaccept-type! acceptable-tag t)
(unaccept-type! acceptable-tag t & more)

Removes identity type t from the given parent acceptable-tag and removes parent :io.randomseed.utils.proto.identity/group from the acceptable tag in the io.randomseed.utils.proto. hierarchy. Makes changes in the global identity type hierarchy io.randomseed.utils.identity.proto/type-hierarchy.

Removes identity type `t` from the given parent `acceptable-tag` and removes parent
`:io.randomseed.utils.proto.identity/group` from the acceptable tag in the `io.randomseed.utils.proto.`
hierarchy. Makes changes in the global identity type hierarchy
`io.randomseed.utils.identity.proto/type-hierarchy`.
sourceraw docstring

valueclj

(value user-identity)
(value identity-type user-identity)

Returns a value of the given identity type user-identity and optional identity type identity-type. If the type is not given, analysis of the given identity will be performed to establish the type first. If the type is given, it must be a valid type, otherwise nil will be returned.

Returns a value of the given identity type `user-identity` and optional identity
type `identity-type`. If the type is not given, analysis of the given identity will
be performed to establish the type first. If the type is given, it must be a valid
type, otherwise `nil` will be returned.
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