What does cardinality mean in this case? (jQuery InputMask)

3

I have the following excerpt:

$('#elemento').inputmask({
    mask: "*{1,255}",
    greedy: false,
    definitions: {
        '*': {
                 validator: "[A-Za-záãâÁÂÃéêẽÈÊẼìîĩÌÎĨòôõÒÔÕùûũÚÛŨ ]",
                 cardinality: 1
             }
        }
});

The question is simple:

  

What does 'cardinality: 1' mean?

Plugin: link

    
asked by anonymous 31.10.2017 / 12:31

1 answer

5

According to the documentation in github, cardinality (Cardinality) defines how many characters represent the definition to be validated.

In your example, the character '*' represents 1 character that will be validated with the regex: [A-Za-záãâÁÂÃéêẽÈÊẼìîĩÌÎĨòôõÒÔÕùûũÚÛŨ ]

Example

$('#elemento1').inputmask({
    mask: "*{1,255}",
    greedy: false,
    definitions: {
       '*': {
           validator: "[A-Za-záãâÁÂÃéêẽÈÊẼìîĩÌÎĨòôõÒÔÕùûũÚÛŨ ]",
           cardinality: 1
       }
    }
});

$('#elemento2').inputmask({
    mask: "*{1,255}",
    greedy: false,
    definitions: {
       '*': {
           validator: "[A-Za-záãâÁÂÃéêẽÈÊẼìîĩÌÎĨòôõÒÔÕùûũÚÛŨ ]",
           cardinality: 2
       }
    }
});

$('#elemento3').inputmask({
    mask: "*{1,255}",
    greedy: false,
    definitions: {
       '*': {
           validator: "[A-Za-záãâÁÂÃéêẽÈÊẼìîĩÌÎĨòôõÒÔÕùûũÚÛŨ ]",
           cardinality: 3
       }
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://rawgit.com/RobinHerbots/Inputmask/4.x/dist/jquery.inputmask.bundle.js"></script>

<input type="text" id="elemento1" />

<p/>
<input type="text" id="elemento2" />

<p/>
<input type="text" id="elemento3" />
    
31.10.2017 / 12:47