UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 1.02 kB
{"version":3,"file":"string.cjs","names":["Result","Identifiers"],"sources":["../../../../src/lib/resolvers/string.ts"],"sourcesContent":["import { Result } from '@sapphire/result';\nimport { Identifiers } from '../errors/Identifiers';\n\nexport function resolveString(\n\tparameter: string,\n\toptions?: { minimum?: number; maximum?: number }\n): Result<string, Identifiers.ArgumentStringTooShort | Identifiers.ArgumentStringTooLong> {\n\tif (typeof options?.minimum === 'number' && parameter.length < options.minimum) {\n\t\treturn Result.err(Identifiers.ArgumentStringTooShort);\n\t}\n\n\tif (typeof options?.maximum === 'number' && parameter.length > options.maximum) {\n\t\treturn Result.err(Identifiers.ArgumentStringTooLong);\n\t}\n\n\treturn Result.ok(parameter);\n}\n"],"mappings":";;;;;AAGA,SAAgB,cACf,WACA,SACyF;AACzF,KAAI,OAAO,SAAS,YAAY,YAAY,UAAU,SAAS,QAAQ,QACtE,QAAOA,yBAAO,IAAIC,2CAAY,uBAAuB;AAGtD,KAAI,OAAO,SAAS,YAAY,YAAY,UAAU,SAAS,QAAQ,QACtE,QAAOD,yBAAO,IAAIC,2CAAY,sBAAsB;AAGrD,QAAOD,yBAAO,GAAG,UAAU"}