File tree 8 files changed +207
-0
lines changed
8 files changed +207
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export * from './index.common'
24
24
export * as Builders from './builders/index.node'
25
25
export * as Factories from './factories/index.node'
26
26
export * as Serialize from './serialize/index.node'
27
+ export * as Validation from './validation/index.node'
27
28
28
29
/**
29
30
* Internal, until the resources-module was finalized and shows any value
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ export class ValidationError extends Error {
21
+ readonly #details: any | undefined
22
+
23
+ constructor ( message ?: string , details ?: any ) {
24
+ super ( message )
25
+ this . #details = details
26
+ }
27
+
28
+ get details ( ) : any | undefined {
29
+ return this . #details
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ export * from './errors'
21
+ export * from './validator'
22
+ export * as Validators from './validators'
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ export interface Validator {
21
+ /**
22
+ * @throws {@link Validation.ValidationError | ValidationError } in case of validation errors
23
+ */
24
+ validate : ( data : any ) => void
25
+ }
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ import { Version } from "../../spec" ;
21
+ import { Validator } from "../validator" ;
22
+
23
+ export abstract class BaseValidator implements Validator {
24
+ readonly #version: Version ;
25
+
26
+ constructor ( version : Version ) {
27
+ this . #version = version
28
+ }
29
+
30
+ get version ( ) : Version {
31
+ return this . #version
32
+ }
33
+
34
+ abstract validate ( data : any ) : void
35
+ }
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ export * from './json'
21
+ export * from './xml'
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ import { ValidationError } from '../errors'
21
+ import { BaseValidator } from './_helpers'
22
+
23
+ export class JsonValidator extends BaseValidator {
24
+ /**
25
+ * @throws {@link Validation.ValidationError | ValidationError } in case of validation errors
26
+ */
27
+ validate ( data : any ) : void {
28
+ // TODO
29
+ throw new ValidationError ( 'not implemented' )
30
+ }
31
+ }
32
+
33
+ export class JsonStrictValidator extends BaseValidator {
34
+ /**
35
+ * @throws {@link Validation.ValidationError | ValidationError } in case of validation errors
36
+ */
37
+ validate ( data : any ) : void {
38
+ // TODO
39
+ throw new ValidationError ( 'not implemented' )
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ /*!
2
+ This file is part of CycloneDX JavaScript Library.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ SPDX-License-Identifier: Apache-2.0
17
+ Copyright (c) OWASP Foundation. All Rights Reserved.
18
+ */
19
+
20
+ import { ValidationError } from '../errors'
21
+ import { BaseValidator } from './_helpers'
22
+
23
+ export class XmlValidator extends BaseValidator {
24
+ /**
25
+ * @throws {@link Validation.ValidationError | ValidationError } in case of validation errors
26
+ */
27
+ validate ( data : any ) : void {
28
+ // TODO
29
+ throw new ValidationError ( 'not implemented' )
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments