akveo / nebular

:boom: Customizable Angular UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/nebular
MIT License
8.07k stars 1.51k forks source link

Changing NbPasswordAuthStrategy validation options doesn't work. #2556

Open Nikitas-io opened 4 years ago

Nikitas-io commented 4 years ago

Issue type

I'm submitting a ... (check one with "x")

Issue description

Current behavior:

Basically, the validation options seem to be usuless. I'm attempting to change the default validation option for the registration form but the default validation options are still there.

Expected behavior:

When chaning the validation options, the validation should actually change. Validation error messages and everything.

Steps to reproduce:

Simply change the validation options in your core.module.ts .

Related code:

My core.module.ts:

export const NB_CORE_PROVIDERS = [
  ...MockDataModule.forRoot().providers,
  ...DATA_SERVICES,
  ...NbAuthModule.forRoot({

    strategies: [
      NbPasswordAuthStrategy.setup({
        name: 'email',

        token: {
          class: NbAuthJWTToken,
          key: 'token', // this parameter tells Nebular where to look for the token
        },

        baseEndpoint: 'http://localhost:3000/api',
        login: {
          redirect: {
            success: '/',
            failure: null, // stay on the same page
          },
          endpoint: '/auth/sign-in',
          method: 'post',
        },
        register: {
          redirect: {
            success: '/',
            failure: null, // stay on the same page
          },
          endpoint: '/auth/sign-up',
          method: 'post',
        },
        logout: {
          redirect: {
            // Take the user back to the login page.
            success: '/auth/login',
            failure: '/auth/login',
          },
          endpoint: '/auth/sign-out',
          method: 'post',
        },
        requestPass: {
          endpoint: '/auth/request-pass',
          method: 'post',
        },
        resetPass: {
          endpoint: '/auth/reset-pass',
          method: 'post',
        },

        // Change the validation options here.
        validation: {
          password: {
            required: true,
            minLength: 6,
          },
          email: {
            required: true
          },
          fullName: {
            required: true,
            minLength: 1,
            maxLength: 30,
            regexp: '/\w+/g',
          }

        }
      }),
    ],

...

    ];

Other information:

npm, node, OS, Browser Node version: v12.18.0 Npm version: 6.14.5 Windows 10 Chrome

Angular, Nebular

"dependencies": {
    "@akveo/ng2-completer": "^9.0.1",
    "@angular/animations": "^10.1.5",
    "@angular/cdk": "^10.2.4",
    "@angular/common": "^10.1.5",
    "@angular/compiler": "^10.1.5",
    "@angular/core": "^10.1.5",
    "@angular/forms": "^10.1.5",
    "@angular/material": "^10.2.4",
    "@angular/platform-browser": "^10.1.5",
    "@angular/platform-browser-dynamic": "^10.1.5",
    "@angular/router": "^10.1.5",
    "@asymmetrik/ngx-leaflet": "3.0.1",
    "@nebular/auth": "6.2.1",
    "@nebular/eva-icons": "5.0.0",
    "@nebular/security": "^6.2.1",
    "@nebular/theme": "^6.2.1",
    "@swimlane/ngx-charts": "^13.0.2",
    "angular2-chartjs": "0.4.1",
    "bootstrap": "4.3.1",
    "chart.js": "^2.9.3",
    "ckeditor": "4.7.3",
    "classlist.js": "1.1.20150312",
    "core-js": "2.5.1",
    "echarts": "^4.8.0",
    "eva-icons": "^1.1.3",
    "intl": "1.2.5",
    "ionicons": "2.0.1",
    "leaflet": "1.2.0",
    "nebular-icons": "1.1.0",
    "ng2-ckeditor": "^1.2.9",
    "ng2-smart-table": "^1.6.0",
    "ngx-echarts": "^4.2.2",
    "node-sass": "^4.14.1",
    "normalize.css": "6.0.0",
    "pace-js": "1.0.2",
    "roboto-fontface": "0.8.0",
    "rxjs": "6.5.4",
    "rxjs-compat": "6.3.0",
    "socicon": "3.0.5",
    "style-loader": "^1.1.3",
    "tinymce": "4.5.7",
    "tslib": "^2.0.0",
    "typeface-exo": "0.0.22",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1001.6",
    "@angular/cli": "^10.1.6",
    "@angular/compiler-cli": "^10.1.5",
    "@angular/language-service": "10.1.5",
    "@compodoc/compodoc": "^1.1.11",
    "@fortawesome/fontawesome-free": "^5.14.0",
    "@types/d3-color": "1.0.5",
    "@types/jasmine": "2.5.54",
    "@types/jasminewd2": "2.0.3",
    "@types/leaflet": "1.2.3",
    "@types/node": "^12.12.54",
    "codelyzer": "^5.1.2",
    "conventional-changelog-cli": "1.3.4",
    "husky": "0.13.3",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "npm-run-all": "4.0.2",
    "protractor": "~7.0.0",
    "rimraf": "2.6.1",
    "stylelint": "7.13.0",
    "ts-node": "3.2.2",
    "tslint": "~6.1.0",
    "typescript": "4.0.3"
  }
AlessioCarosiniCap commented 1 year ago

same problem, have you find a solution?

peekyou commented 1 year ago

After checking the source code, it's looking for validations under forms object: getConfigValue('forms.validation.password.minLength')

Change your config to the below, it should work

forms: {
  validation: {
    password: {
      required: true,
      minLength: 6,
    },
    email: {
      required: true
    },
    fullName: {
      required: true,
      minLength: 1,
      maxLength: 30,
      regexp: '/\w+/g',
    }
  }
}