sap-cap-validator-plugin
A CAP plugin that checks incoming data against JSON Schema rules written as @Validator annotations on model elements, evaluated by Ajv, with no handler to register.
Puts the rule next to the element it guards: @Validator: {format: 'email'} on a field, and data that does not match is rejected. The rules are evaluated by AjvAjvA JSON Schema validator for JavaScript. Where something here validates against JSON Schema rather than against the CDS model, Ajv is what compiles the schema and runs it., so any draft-07 keyword Ajv implements can be used, which is how it reaches formats a CDS model has no assertion of its own for: duration, uri, url, email, hostname, ipv4, ipv6 and a date-time string. Installing the package and annotating the entities is the whole setup, with no handler to register and nothing to call from a service implementation.
Facts
Where it sits
Who is behind it
In the atlas: maintains 16, contributes to 41, wrote 4@mauriciolauffermaintainer
Before choosing this
Signals
ActivityQuietRelease and repository quiet for 30 months
Both observable publication channels have been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
- § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
PracticalFunctional boundary
The annotation sits on a single element, so a rule that spans two fields, or one that needs a lookup, has nowhere in it to go.
What it declares
Every artifact
- Type
- CDS plugin
- Origin
- Independently maintained
- Runtime
- Node.js
As a CDS plugin
- Declared for
- >=7
- Distributed through
- npm
Connections
Rejecting bad input before it reaches a handler
A JSON Schema validator for JavaScript. Where something here validates against JSON Schema rather than against the CDS model, Ajv is what compiles the schema and runs it.
Download
Install
npm add sap-cap-validator-pluginDerived from the package name. No recipe recorded; the README has the configuration.
Where it sits in your app
Download
README
quoted from mauriciolauffer/sap-cap-validator-plugin under MIT, readSAP CAP Validator Plugin
A SAP CAP plugin to validate incoming data.
This plugin uses Ajv, a JSON schema validator. All validation keywords available in Ajv (draft-07) can be used.
Setup
All you need to do is to install the plugin and add the @Validator annotations to your entities.
Installation
Install the plugin as an npm module:
npm install sap-cap-validator-plugin
Annotation
The annotation tag is @Validator. You can add and combine valid rules from JSON Schema such as types and formats
using {myService as service} from './services';
annotate service.myEntity with {
field_duration @Validator: {format: 'duration'};
field_uri @Validator: {format: 'uri'};
field_url @Validator: {format: 'url'};
field_email @Validator: {format: 'email'};
field_hostname @Validator: {format: 'hostname'};
field_ipv4 @Validator: {format: 'ipv4'};
field_ipv6 @Validator: {format: 'ipv6'};
field_datetime @Validator: {
type: 'string',
format: 'date-time'
};
};History
v0.0.2
Others providing
Compare all 8 on the Input validation page →- abapDomCheckabapDomCheckChecks a structure's field values against ABAP domain fixed values and check tables outside the GUI, such as during a data import, answering with a rejected flag and the messages behind it.independent, abapChecks field values against domain fixed values and check tablesfrom ABAP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- cap-toolkitcap-toolkitA utility bundle for CAP handlers, with a chainable HandlerBuilder, role checks, validation rules and query helpers, collecting boilerplate that otherwise repeats across projects into one dependency.independent, capUtility bundle for CAP handlers: builder, roles, validation, queriesfrom CAP
- abap-data-validatorabap-data-validatorA validation library for ABAP that checks values such as dates, emails, URLs, JSON and GUIDs against type rules through one interface, or a whole internal table against a set of rules.independent, abapValidation library for ABAP checking dates, emails and GUIDsfrom ABAP
- capvalcapvalReplaces the message a failed input validation annotation returns, and adds @validation.handler, which names a class that runs a check of the developer's own.independent, capCustom messages and handler classes for CAP input validationfrom CAP
- cds-validatecds-validateA package that runs Zod schemas as CAP validation middleware, so one schema replaces the hand-written checks at the top of a handler and failures come back as OData 422 errors per field.independent, capZod schemas as CAP validation middlewarefrom CAP
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtimefrom CAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:mauriciolauffer-sap-cap-validator-plugin- JSON
- /artifacts/mauriciolauffer-sap-cap-validator-plugin.json
- MCP
- Connecting an agent