diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e80bc24..8a642c2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,7 +21,7 @@ jobs: distribution: 'zulu' - name: Cache local Maven repository - uses: actions/cache@v2.1.6 + uses: actions/cache@v3 with: path: ~/.m2/ key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }} @@ -29,5 +29,7 @@ jobs: - name: Build with Maven run: mvn clean verify - - name: Upload codecov report - uses: codecov/codecov-action@v1.5.2 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/src/main/java/br/ufsc/bridge/platform/validation/rules/CnsRule.java b/src/main/java/br/ufsc/bridge/platform/validation/rules/CnsRule.java index f95a6ce..8045531 100644 --- a/src/main/java/br/ufsc/bridge/platform/validation/rules/CnsRule.java +++ b/src/main/java/br/ufsc/bridge/platform/validation/rules/CnsRule.java @@ -6,7 +6,7 @@ public class CnsRule implements Rule { private final static String CNS1 = "^[1-2][0-9]{10}00[0-1][0-9]$"; - private final static String CNS2 = "^[7-9][0-9]{14}$"; + private final static String CNS2 = "^[57-9][0-9]{14}$"; @Override public String validate(String value) { if (!Util.isEmpty(value) && !this.isValid(value)) { diff --git a/src/main/script/rules/cns.ts b/src/main/script/rules/cns.ts index 95f7593..cbfc70c 100644 --- a/src/main/script/rules/cns.ts +++ b/src/main/script/rules/cns.ts @@ -3,7 +3,7 @@ import { msg } from '..' import { length } from './length' const CNS1 = '^[1-2][0-9]{10}00[0-1][0-9]$' -const CNS2 = '^[7-9][0-9]{14}$' +const CNS2 = '^[57-9][0-9]{14}$' function somaPonderada(cnsValue: string) { let soma = 0 diff --git a/src/test/java/br/ufsc/bridge/platform/validation/rules/CnsTest.java b/src/test/java/br/ufsc/bridge/platform/validation/rules/CnsTest.java index 7fb355c..35eebc7 100644 --- a/src/test/java/br/ufsc/bridge/platform/validation/rules/CnsTest.java +++ b/src/test/java/br/ufsc/bridge/platform/validation/rules/CnsTest.java @@ -18,6 +18,8 @@ public void testarRequired() { public void testarValorDeCns() { Assert.assertNull("975055825130003 é um Cns válido", this.validate("975055825130003", Rules.cns)); + Assert.assertNull("586309087428878 é um Cns válido", this.validate("586309087428878", Rules.cns)); + Assert.assertNull("118725165660004 é um Cns válido", this.validate("118725165660004", Rules.cns)); Assert.assertNull("218342347130008 é um Cns válido", this.validate("218342347130008", Rules.cns)); @@ -30,6 +32,8 @@ public void testarValorDeCns() { Assert.assertNotNull("O Cns é invalido", this.validate("109878998754646", Rules.cns)); + Assert.assertNotNull("O Cns é invalido", this.validate("594516874912612", Rules.cns)); + Assert.assertNotNull("O Cns é invalido", this.validate("236951545487965", Rules.cns)); Assert.assertNotNull("O Cns é invalido", this.validate("478976532213336", Rules.cns)); @@ -46,8 +50,6 @@ public void testarValorDeCns() { Assert.assertNotNull("O Cns não pode comeaçar com 4", this.validate("431439904710009", Rules.cns)); - Assert.assertNotNull("O Cns não pode comeaçar com 5", this.validate("562593396660002", Rules.cns)); - Assert.assertNotNull("O Cns não pode comeaçar com 6", this.validate("667429114440003", Rules.cns)); Assert.assertNotNull("111111111111111 não é um Cns válido", this.validate("111111111111111", Rules.cns));