MCPcopy
hub / github.com/Effect-TS/effect / makeStringConstraints

Function makeStringConstraints

packages/effect/src/Arbitrary.ts:72–91  ·  view source on GitHub ↗
(options: {
  readonly minLength?: number | undefined
  readonly maxLength?: number | undefined
  readonly pattern?: string | undefined
})

Source from the content-addressed store, hash-verified

70
71/** @internal */
72export const makeStringConstraints = (options: {
73 readonly minLength?: number | undefined
74 readonly maxLength?: number | undefined
75 readonly pattern?: string | undefined
76}): StringConstraints => {
77 const out: Types.Mutable<StringConstraints> = {
78 _tag: "StringConstraints",
79 constraints: {}
80 }
81 if (Predicate.isNumber(options.minLength)) {
82 out.constraints.minLength = options.minLength
83 }
84 if (Predicate.isNumber(options.maxLength)) {
85 out.constraints.maxLength = options.maxLength
86 }
87 if (Predicate.isString(options.pattern)) {
88 out.pattern = options.pattern
89 }
90 return out
91}
92
93interface NumberConstraints {
94 readonly _tag: "NumberConstraints"

Callers 2

Arbitrary.tsFile · 0.85
mergeStringConstraintsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…