wishlist-client/components/domain/wishes/models.ts

27 lines
479 B
TypeScript
Raw Normal View History

2022-04-24 23:12:11 +02:00
import { result } from '../../common/result'
export type Wish = {
2022-04-25 22:32:24 +02:00
id: string
2022-04-24 23:12:11 +02:00
name: string
description?: string
link?: string
}
export const createWish = (
2022-04-25 22:32:24 +02:00
id: string,
2022-04-24 23:12:11 +02:00
name: string,
2022-04-25 22:32:24 +02:00
description: string = '',
link: string = ''
2022-04-24 23:12:11 +02:00
): result.Result<Wish, string> => {
2022-04-25 22:32:24 +02:00
if (typeof name !== 'undefined') {
2022-04-24 23:12:11 +02:00
return result.ok({
2022-04-25 22:32:24 +02:00
id,
2022-04-24 23:12:11 +02:00
name,
description,
link,
} as Wish)
}
return result.err(`validation of wish failed via. createWish`)
}