npm i @junaid1460/forms-annotationstypescript 3 (es6)
import{Forms}from'.';
@Forms.FormclassActionButton{
@Forms.Input().Validate(e=>e.string().required())publicaction: string;}
@Forms.FormclassAnotherForm{
@Forms.Input().Validate(e=>e.string().required())publiclabel?: string;}// CustomizeconstRequiredText=()=>Forms.Input().Validate(e=>e.string().required())
@Forms.FormclassMyFormextendsForms.BaseForm<MyForm>{
@RequiredText()name?: any
@Forms.Input({dtype: "email"})
@Forms.Validate(e=>e.string().required())email: string
@Forms.Select({options: [{value: "values",view_value: "sdfsdf"},{value: "another",view_value: ""}]})options?: any
@Forms.Branch<MyForm>({branch_key: "options",branches:()=>({values: ActionButton,another: AnotherForm})})test?: any
@Forms.SubSchema({schema: AnotherForm})value: AnotherForm;}constdata=newMyForm({email: 'junaid1460@gmail.com',name: "junaid",options: "values",test: {label: "My label"},value: {label: "Hello world"}})console.log(data.validate().then(e=>console.log(e)))console.log(MyForm.getValidationSchema())console.log(MyForm.getUISchema())console.log(data)/** example.ts:65 internals.Object {isJoi: true, _currentJoi: module.exports.internals.Any, _type: "object", _settings: null, _baseType: undefined, …} example.ts:66 Array(5) [Object, Object, Object, Object, Object] example.ts:67 MyForm {email: "Test", name: "he", options: "values", test: Object, value: Object} example.ts:68 (node:6365) UnhandledPromiseRejectionWarning: ValidationError: child "test" fails because [child "action" fails because ["action" is required]] at Object.exports.process (/Users/muhammadjunaid/loco/forms-annotations/node_modules/joi/lib/errors.js:203:19) at internals.Object._validateWithOptions (/Users/muhammadjunaid/loco/forms-annotations/node_modules/joi/lib/types/any/index.js:764:31) at internals.Object.validate (/Users/muhammadjunaid/loco/forms-annotations/node_modules/joi/lib/types/any/index.js:798:21) at validate.Promise (/Users/muhammadjunaid/loco/forms-annotations/src/index.ts:31:23) at new Promise (<anonymous>) at MyForm.validate (/Users/muhammadjunaid/loco/forms-annotations/src/index.ts:29:20) at Object.<anonymous> (/Users/muhammadjunaid/loco/forms-annotations/src/example.ts:65:18) at Module._compile (internal/modules/cjs/loader.js:773:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) warning.js:18 */