nuxt-property-decorator icon indicating copy to clipboard operation
nuxt-property-decorator copied to clipboard

Add validation decorators

Open marcin-stasiak opened this issue 5 years ago • 4 comments

Consider adding decorators for validation for example: https://www.npmjs.com/package/vuelidate-property-decorators

marcin-stasiak avatar May 10 '20 14:05 marcin-stasiak

cc @husayt what do you think of this?

atinux avatar Jan 15 '21 10:01 atinux

Here we mainly add decorators specific to core nuxt features e.g. router, vuex, vue-meta. Decorators for other libraries can easily be added separately. @marcin-stasiak I suggest to add that separtely. I am very conscious that this library is already doing too much.

@atinux going forward this library will shape depending on vue 3 related changes in next versions of vue-class-component and nuxt. Can I have access to nuxt-next for vue3 to give it a try as Vue Class Component v8 is already available in beta,

husayt avatar Jan 15 '21 18:01 husayt

Here we mainly add decorators specific to core nuxt features e.g. router, vuex, vue-meta. Decorators for other libraries can easily be added separately. @marcin-stasiak I suggest to add that separtely. I am very conscious that this library is already doing too much.

@Atinux going forward this library will shape depending on vue 3 related changes in next versions of vue-class-component and nuxt. Can I have access to nuxt-next for vue3 to give it a try as Vue Class Component v8 is already available in beta,

I tried to use one of such "other libraries" - vuelidate-property-decorators with nuxt, but it fails. It gets me an error:

SyntaxError
Unexpected token 'export'

I have these in package.json:

// dependencies:
"vue-property-decorator": "9.1.2",
"vuelidate-property-decorators": "^1.0.28"
"@vuelidate/validators": "^2.0.0-alpha.14",

And this in the file where I'm trying to use it:

<template>
    ....
    <s-input
        v-model="$v.search.$model"
        placeholder="..."
        clearable
        @focus="handleSearchActiveChange"
        @blur="handleSearchActiveChange"
    />
    ....
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import { Validate } from 'vuelidate-property-decorators'
import { required } from '@vuelidate/validators'

...

@Component({ ... })
export default class HeaderMain extends Vue {
    @Validate({ required })
    search = null
    ...
}
</script>

And once I comment { Validate } import and decorator from search - the error is gone, while required works okay and i can even render it in the template, so the problem is related exactly to import from vuelidate-property-decorator. So it seems it's not that simple :(

TrayHard avatar May 19 '21 19:05 TrayHard

@TrayHard

I tried to use one of such "other libraries" - vuelidate-property-decorators with nuxt, but it fails. It gets me an error:

SyntaxError
Unexpected token 'export'

this helped me add in nuxt.config.js build: { transpile: ['vuelidate'], },

grandmasteralexandr avatar Jun 18 '21 14:06 grandmasteralexandr