File tree Expand file tree Collapse file tree
test/jest/__tests__/store Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 <pre >{{ cffstr }}</pre >
3636 </q-card-section >
3737 </q-card >
38+ <div class =" row justify-center q-pt-md" >
39+ <p >
40+ Your CITATION.cff is  ;
41+ </p >
42+ <span v-if =" isValid" >valid</span >
43+ <span v-else >invalid</span >
44+ </div >
3845</template >
3946
4047<script lang="ts">
41- import { defineComponent , ref } from ' vue'
48+ import { defineComponent , ref , computed } from ' vue'
4249import { useCffstr } from ' src/store/cffstr'
50+ import { isValidCffFile } from ' src/validator'
4351
4452export default defineComponent ({
4553 name: ' Preview' ,
4654 setup () {
47- const cffstr = useCffstr ()
55+ const { cffstr } = useCffstr ()
4856 const showTooltip = ref (false )
4957
5058 const copyToClipboard = async () => {
@@ -54,9 +62,12 @@ export default defineComponent({
5462 showTooltip .value = false
5563 }
5664
65+ const isValid = computed (isValidCffFile )
66+
5767 return {
5868 cffstr ,
5969 copyToClipboard ,
70+ isValid ,
6071 showTooltip
6172 }
6273 }
Original file line number Diff line number Diff line change @@ -70,5 +70,8 @@ export function useCffstr () {
7070 return yaml . dump ( kebabed , { indent : 2 , sortKeys : true } )
7171 }
7272
73- return computed ( ( ) => makeCffstr ( ) )
73+ return {
74+ jsObject : computed ( makeJavascriptObject ) ,
75+ cffstr : computed ( makeCffstr )
76+ }
7477}
Original file line number Diff line number Diff line change 11import Ajv from 'ajv'
22import addFormats from 'ajv-formats'
33import schema from './schemas/1.2.0/schema.json'
4+ import { useCffstr } from './store/cffstr'
45
56export const ajv = new Ajv ( )
67addFormats ( ajv )
78ajv . addSchema ( schema )
89
10+ export const isValidCffFile = ( ) => {
11+ const { jsObject } = useCffstr ( )
12+ return ajv . validate ( `${ schema . $id } ` , jsObject . value )
13+ }
14+
915export const makeFieldValidator = ( subschema : string ) => {
1016 return ( val : unknown ) => {
1117 const isValid = ajv . validate ( `${ schema . $id } #${ subschema } ` , val )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { useCffstr } from '../../../../src/store/cffstr'
44
55describe ( 'useCffstr' , ( ) => {
66 const cff = useCff ( )
7- const cffstr = useCffstr ( )
7+ const { cffstr } = useCffstr ( )
88
99 beforeEach ( ( ) => {
1010 cff . reset ( )
You can’t perform that action at this time.
0 commit comments