import { ValueObject } from '@server/shared/src/core/domain/ValueObject' ; import { Result } from '@server/shared/src/core/logic/Result' ; export interface ITagSlugProps { value : string ; } export class TagSlug extends ValueObject < ITagSlugProps > { get value ( ) : string { return this . props . value ; } private constructor ( props ) { super ( props ) ; } private static format ( slug ) { return slug . toLocaleLowerCase ( ) . replace ( /[^\w ^-]+/g , '' ) . replace ( / +/g , '-' ) ; } public static createFromIntegration ( title , integrationId ? ) { const slug = this . format ( title ) . concat ( integrationId ? `-${ integrationId }` : '' ) ; return Result . ok ( new TagSlug ( { value : slug } ) ) ; } public static create ( slug ) { return Result . ok ( new TagSlug ( { value : this . format ( slug ) } ) ) ; } }