Make typeguards for newtypes match the type instead of isString or isNumber.
This commit is contained in:
parent
f296c6fe26
commit
72543b95ee
3 changed files with 34 additions and 21 deletions
server/types
|
@ -1,11 +1,14 @@
|
|||
import {ArrayField, Field, RawJsonField} from "sparkson"
|
||||
import {ClientConfig, JSONObject, Url} from "./shared";
|
||||
|
||||
// TODO: Replace string types by more specific types like URL, Password, etc.
|
||||
import {ClientConfig, isSite, isString, JSONObject, toIsNewtype, Url} from "./shared";
|
||||
|
||||
export type Username = string & { readonly __tag: unique symbol };
|
||||
export const isUsername = toIsNewtype(isString, "" as Username);
|
||||
|
||||
export type CleartextPassword = string & { readonly __tag: unique symbol };
|
||||
export const isCleartextPassword = toIsNewtype(isString, "" as CleartextPassword);
|
||||
|
||||
export type PasswordHash = string & { readonly __tag: unique symbol };
|
||||
export const isPasswordHash = toIsNewtype(isString, "" as PasswordHash);
|
||||
|
||||
export class UsersConfig {
|
||||
constructor(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue