Skip to content
Myr

chore: denoify

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by Yusuke Wada · parent 35ab653 · Browse files · 1 file+9 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−8 removed

  • other:+9 added−8 removed

1 file+9 added−8 removed

modified:deno_dist/validator/validator.ts+9 added-8 removed
86 unmodified lines
87 }88}8990export class Validator {91 isArray: boolean = false91 constructor(private inArray: boolean = false) {}9293 query = (key: string): VString => new VString({ target: 'query', key: key })94 queries = (key: string): VStringArray => new VStringArray({ target: 'queries', key: key })95 header = (key: string): VString => new VString({ target: 'header', key: key })96 body = (key: string): VString => new VString({ target: 'body', key: key })97 json = (key: string) => {97 if (this.isArray) {98 if (this.inArray) {99 return new VStringArray({ target: 'json', key: key })100 } else {101 return new VString({ target: 'json', key: key })102 }103 }103 array = <T extends Schema>(path: string, validator: (v: Validator) => T): VArray<T> => {104 this.isArray = true105 const res = validator(this)104 array = <T extends Schema>(path: string, validatorFn: (v: Validator) => T): VArray<T> => {105 const validator = new Validator(true)106 const res = validatorFn(validator)107 const arr = new VArray(res, path)108 return arr109 }109 object = <T extends Schema>(path: string, validator: (v: Validator) => T): VObject<T> => {110 this.isArray = false111 const res = validator(this)110 object = <T extends Schema>(path: string, validatorFn: (v: Validator) => T): VObject<T> => {111 const validator = new Validator(this.inArray)112 const res = validatorFn(validator)113 const obj = new VObject(res, path)114 return obj115 }116}
387 unmodified lines