udos86 / ng-dynamic-forms

Rapid form development library for Angular
ISC License
1.32k stars 369 forks source link

add min and max for dateinputs #206

Closed JBusch closed 7 years ago

JBusch commented 7 years ago

Wouldn't it be nice, if we could set min and max for date inputs? we could easily set them which would make a lot of validation obsolete imho.

udos86 commented 7 years ago

@JBusch I would not like to add these properties to DynamicInputModel as this is not part of the HTML 5 standard. However I'm planning to introduce a DynamicDatePickerModel as soon as Material 2 does deliver a corresponding UI control. There, your proposal could make a nice addition.

Thanks for your ideas!

JBusch commented 7 years ago

well, do i read it false then? https://www.w3.org/TR/html51/sec-forms.html#date-state-typedate

The following common input element content attributes, IDL attributes, and methods apply to the element: autocomplete, list, max, min, readonly, required, and step content attributes; list, value, valueAsDate, and valueAsNumber IDL attributes; select(), stepDown(), and stepUp() methods.

udos86 commented 7 years ago

@JBusch Oh, you're right. I originally thought that min and max attributes would only apply to input type number. Nevertheless you can already set min and max properties for DynamicInputModel.

JBusch commented 7 years ago

you can already set min and max properties for DynamicInputModel

well, those on the input model are numbers. we would need dates here though, right?

udos86 commented 7 years ago

@JBusch I'm not sure. Shouldn't it be number | string? (see http://www.w3schools.com/tags/att_input_min.asp)

JBusch commented 7 years ago

Jap, valid date string is fine. i'll check it out.

JBusch commented 7 years ago

Yes, it already works just by setting the min attribute on the input model!

JBusch commented 7 years ago

well, min and max are only number right now, which throws an error:

export interface DynamicInputModelConfig extends DynamicInputControlModelConfig {
    accept?: string;
    inputType?: string;
    list?: Array<string>;
    max?: number;
    min?: number;
    multiple?: boolean;
    pattern?: string;
    step?: number;
}
export declare class DynamicInputModel extends DynamicInputControlModel<any> {
    accept: string | null;
    inputType: string;
    files: FileList | null;
    list: Array<string> | null;
    max: number | null;
    min: number | null;
    multiple: boolean | null;
    pattern: string | null;
    step: number | null;
    private listId;
    readonly type: string;
    constructor(config: DynamicInputModelConfig, cls?: ClsConfig);
}
JBusch commented 7 years ago

A DynamicDatePickerModel would be really nice btw. Type "date" is so sad right now :(

udos86 commented 7 years ago

@JBusch types will be adjusted in the next patch version 1.3.2