uNmAnNeR / imaskjs

vanilla javascript input mask
https://imask.js.org
MIT License
4.96k stars 258 forks source link

Cron Expression Mask #1091

Open renerlemes opened 1 week ago

renerlemes commented 1 week ago

I´m try to creating a mask in format: * * * * * in which is used in Cron Expression. I´m using IMask.createMask, without UI

const masked = IMask.createMask({
        mask: "0 0 0 0 0 0",
        blocks: {
            // Minutes
            "1": {
                mask: /^[*]|[0-5]?\d$/
            },
            // Hour
            "2": {
                mask: /^[*]|([01]?\d|2[0-3])$/
            },
            // Day of month
            "3": {
                mask: /^[*]|([01]?\d|2\d|3[01])$/
            },
            // Month
            "4": {
                mask: /^[*]|1[0-2]|0?[1-9]$/
            },
            // Day of week
            "5": {
                mask: /^[*]|[0-7]$/
            }
        },
        prepare: (str) => str.trim()
    });

    const value = "11122";

    masked.resolve(value, {});
        //masked.resolve(value);

    console.log("value", value);
    console.log("masked.value", masked.value); //11122
    console.log("masked.unmaskedValue", masked.unmaskedValue); //11122

https://codesandbox.io/p/sandbox/componentes-mask-nnzvfl?file=%2Fsrc%2Fcomponents%2FCronExpression.tsx%3A32%2C26

But the masked should be 1 1 1 2 2 2

Could someone help me?