# JSchema Typescript Rozszerzenia JSChema pod TypeScript, zamiana schematu na klasy TypeScript i zamiana klas TypeScript na schemat Aby korzystać z dekoratorów nalezy ustawić w `tsconfig.json` ```JSON { "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true } } ``` Przykład uzycia: ```TypeScript import {SchemaProperty,SchemaValidator,SchemaWarning,classToSchema} from '@witkac/jschema-typescript' class Model { @SchemaProperty() public firstName: string = 'Daniel'; @SchemaProperty() public needName: boolean = true; @SchemaValidator() public firstName_required(): boolean { return this.needName; } @SchemaValidator() public firstName_disabled(): boolean { return !this.needName; } @SchemaValidator({ message: 'minimalna długość to {{minLength}}' }) public firstName_minLength(): number { return 5 + 23; } @SchemaWarning({ validator: 'maxLength', message: 'zalecana maksymalna długość to {{maxLength}}' }) public firstName_maxLength22(): number { return 70; } @SchemaValidator() public firstName_title(): string { return this.needName ? 'Imię (wymagane)' : 'Imię'; } } const schema = classToSchema(Model, false); ``` ## SchemaProperty domyslne oznaczenie pola w schemacie, mozliwośc dodania władciwości ```TypeScript @SchemaProperty({minLength: 23}) public firstName: string = 'Daniel'; ``` ## SchemaMoney odpowiednik ```TypeScript @SchemaProperty({type: 'money'})` ``` ## SchemaDebug odpowiednik ```TypeScript @SchemaProperty({debug: true})` ``` ## SchemaCalc ```TypeScript SchemaCalc(func: string | string[], when?: string) ``` odpowiednik ```TypeScript @SchemaProperty({calc: func})` ```