@yyasinaslan/easyform
Version:
Angular Easy Form
80 lines (79 loc) • 2.57 kB
TypeScript
import { FormFieldBase } from "./interfaces/form-field";
import { BasicControlTypes } from "./interfaces/basic-control-types";
import { AdvancedControlTypes } from "./interfaces/advanced-control-types";
import { Validation } from "./interfaces/validation";
import { ValidatorFn } from "@angular/forms";
import { ObservableString } from "./interfaces/observable-string";
import { SelectOptions } from "./interfaces/select-options";
import { FormSchema } from "./interfaces/form-schema";
export declare class EasyFormField<FormType = any> implements FormFieldBase<FormType> {
id?: string;
label?: ObservableString;
hint?: string;
/**
* The type of control to be rendered
*/
controlType: string | BasicControlTypes | AdvancedControlTypes;
validations: Record<string, Validation>;
props?: Record<string, any>;
initialValue?: FormType;
options?: SelectOptions<any>;
schema?: EasyFormField<FormType> | FormSchema<FormType>;
constructor(options: FormFieldBase<FormType>);
/**
* Add a required validation to the field
* @param message
*/
required(message: ObservableString): this;
/**
* Add a requiredTrue validation to the field
* @param message
*/
requiredTrue(message: ObservableString): this;
/**
* Add a minLength validation to the field
* @param minLength
* @param message
*/
minLength(minLength: number, message: ObservableString): this;
/**
* Add a maxLength validation to the field
* @param maxLength
* @param message
*/
maxLength(maxLength: number, message: ObservableString): this;
/**
* Add an email validation to the field
* @param message
*/
email(message: ObservableString): this;
/**
* Add a pattern validation to the field
* @param pattern
* @param message
*/
pattern(pattern: string | RegExp, message: ObservableString): this;
/**
* Add a min validation to the field
* @param min
* @param message
*/
min(min: number, message: ObservableString): this;
/**
* Add a max validation to the field
* @param max
* @param message
*/
max(max: number, message: ObservableString): this;
/**
* Add a custom validation to the field
* @param validator
* @param messages
*/
customValidator(validator: ValidatorFn, messages: Record<string, ObservableString>): this;
/**
* Set the initial value of the field
* @param value
*/
default(value: FormType): this;
}