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

Asked

Viewed 81 times

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 it mean 'cardinality: 1' ?

Plugin: https://github.com/RobinHerbots/Inputmask

  • As it is in the link: " Cardinality specifies how many characters are represented and validated for the definition"

  • @Everson this yes, but I don’t understand what that means exactly kk

1 answer

5


According to the documentation on github a 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 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>
<script src="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" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.