You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
import {UniversalPath} from '../../util'
|
|
import {Template} from '../../cli'
|
|
|
|
const form_template: Template = {
|
|
name: 'form',
|
|
fileSuffix: '.form.ts',
|
|
description: 'Create a new form request validator',
|
|
baseAppPath: ['http', 'forms'],
|
|
render(name: string, fullCanonicalName: string, targetFilePath: UniversalPath) {
|
|
return `import {FormRequest, ValidationRules, Rule} from '@extollo/forms'
|
|
import {Injectable} from '@extollo/di'
|
|
|
|
/**
|
|
* ${name} object
|
|
* ----------------------------
|
|
* This is the object interface that is guaranteed when
|
|
* all of the validation rules below pass.
|
|
*/
|
|
export interface ${name}Form {
|
|
|
|
}
|
|
|
|
/**
|
|
* ${name}Request validator
|
|
* ----------------------------
|
|
* Request validator that defines the rules needed to guarantee
|
|
* that a request's input conforms to the interface defined above.
|
|
*/
|
|
@Injectable()
|
|
export class ${name}FormRequest extends FormRequest<${name}Form> {
|
|
/**
|
|
* The validation rules that should be applied to the various
|
|
* request input fields.
|
|
* @protected
|
|
*/
|
|
protected getRules(): ValidationRules {
|
|
return {
|
|
|
|
}
|
|
}
|
|
}
|
|
`
|
|
}
|
|
}
|
|
|
|
export { form_template }
|