Open parischap opened 11 months ago
Schema interoperates with effect/Data. The Schema.data(schema) combinator can be used to build a schema from an existing schema that can decode a value A to a value Data. However, the equality operator of the produced Data is not always appropiate. It often happens that we need the equality operator to bear only on a subgroup of A's properties. For instance:
Schema.data(schema)
export class Person extends Data.Class<{ readonly id: string; readonly firstName: string; readonly lastName: string; readonly address: string; }> { [Equal.symbol] = (that: Equal.Equal): boolean => that instanceof Person ? this.id=== that.id : false; [Hash.symbol] = (): number => Hash.hash(this.id); }
Add a .notInEqual combinator:
const person= S.data( S.struct({ id: S.string, firstName: pipe(S.string,S.notInEqual), lastName: pipe(S.string,S.notInEqual), address: pipe(S.string,S.notInEqual), }) );
could be an underlying feature of Data and an option to S.data()
Data
S.data()
What is the problem this feature would solve?
Schema interoperates with effect/Data. The
Schema.data(schema)
combinator can be used to build a schema from an existing schema that can decode a value A to a value Data. However, the equality operator of the produced Data is not always appropiate. It often happens that we need the equality operator to bear only on a subgroup of A's properties. For instance:What is the feature you are proposing to solve the problem?
Add a .notInEqual combinator:
What alternatives have you considered?