Page MenuHomeSealhub

value-not-existing-in-collection.ts
No OneTemporary

value-not-existing-in-collection.ts

import ValueExistingInCollection from "./value-existing-in-collection";
import { Context, Field } from "../../../main";
export default class ValueNotExistingInCollection extends ValueExistingInCollection {
getTypeName = () => "value-not-existing-in-collection";
async isProperValue(
context: Context,
new_value: unknown,
old_value: unknown
) {
const field = this.getField(context.app);
await field.checkValue(context, new_value, old_value, null);
if (this.include_forbidden) {
context = new this.app.SuperContext();
}
const sealious_response = await field.collection
.list(context)
.filter({ [field.name]: new_value })
.fetch();
if (!sealious_response.empty) {
return Field.invalid(
context.app.i18n("invalid_non_existing_value", [
field.collection.name,
field.name,
new_value,
])
);
}
return Field.valid();
}
}

File Metadata

Mime Type
text/x-java
Expires
Sun, Jul 13, 04:56 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
778480
Default Alt Text
value-not-existing-in-collection.ts (880 B)

Event Timeline